自从 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/