gpt4 book ai didi

android - 如何将 drawable 文件夹中的图像添加到 Android Studio 1.2 中的 ImageView?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:36:52 24 4
gpt4 key购买 nike

自从 Google 为启动器图标添加了 mipmap 文件夹后,我在使用 drawables 文件夹时遇到了问题。我在 drawable 文件夹中手动添加了 hdpi 文件夹,但是当我尝试添加 src 路径时,图像不允许我查看和选择它们。如何将 drawable 文件夹中的图像添加到 Android Studio 1.2 中的 ImageView?

最佳答案

尝试使用这种代码方式,可以通过三种方式在 ImageView 上设置图像

imageView.setImageResource(R.drawable.play);

            <ImageView
android:id="@+id/ivProfileBg"
android:src="@drawable/image_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

              <ImageView
android:id="@+id/ivProfileBg"
android:background="@drawable/image_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

关于android - 如何将 drawable 文件夹中的图像添加到 Android Studio 1.2 中的 ImageView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30154989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com