如何设置图像的ImageView? [英] How to set image in ImageView?

查看:110
本文介绍了如何设置图像的ImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要把我自己的形象上的一些的ImageView 。所以这就是为什么我创建的文件夹命名为res文件夹绘制,并复制我的形象在此文件夹中,但现在我不知道如何将此图像设置为我的的ImageView 在XML code。任何人可以帮助?和遗憾,对英语:)

I need to put my own image on some imageView. So that's why I created folder named "drawable" in res folder , and copy my Image in this folder , but now I don't know how to set this image to my imageView in XML code. Can anybody help? and sorry for English :)

推荐答案

在您的布局XML文件:

In your layout XML file:

<ImageView android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/your_image_name"/>

替换 your_image_name 与不带扩展名的图像文件的名称(例如,如果您绘文件名为 img1.png 的src 属性应该有 @绘制/ IMG1 )。

Replace your_image_name with the name of the image file without the extension (e.g. if your drawable file is called img1.png, the src attribute should have a value of @drawable/img1).

这篇关于如何设置图像的ImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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