您的位置:首页 > 移动开发 > Android开发

android开发文档之resource-drawable用法

2013-04-22 11:28 429 查看
Android developer文档中有对resource的drawable进行详细介绍

现在我们就一一介绍:


Bitmap File

A bitmap file is a
.png
,
.jpg
, or
.gif
file.
Android creates a
Drawable
resource for
any of these files when you save them in the
res/drawable/
directory.

文件路径
res/drawable/filename.png
(
.png
,
.jpg
,
or
.gif
)

The filename is used as the resource ID.compiled resource datatype:Resource pointer to a
BitmapDrawable
.引用方式:In Java:
R.drawable.filename


In XML:
@[package:]drawable/filename
example:With an image saved at
res/drawable/myimage.png
, this layout XML applies the image to a View:
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/myimage" />

The following application code retrieves the image as a
Drawable
:
Resources res = [code]getResources()
;
Drawable drawable = res.
getDrawable
(R.drawable.myimage);[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: