如何将可绘制文件夹中的图像添加到Android Studio 1.2中的ImageView? [英] How do I add an image in the drawable folder to an ImageView in Android Studio 1.2?

查看:528
本文介绍了如何将可绘制文件夹中的图像添加到Android Studio 1.2中的ImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Since Google added the mipmap folder for the launcher icons, I have had issues using the drawables folder. I manually added the hdpi folders in the drawable folder, but when I try and add the src path, the images won't allow me to view and select them. How do I add an image in the drawable folder to an ImageView in Android Studio 1.2?

推荐答案

尝试使用这种代码方式有三种在ImageView上设置图像的方法

try with this way of code there are three ways to set image on 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 Studio 1.2中的ImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆