android开发文档之resource-drawable用法

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 = getResources();
Drawable drawable = res.getDrawable(R.drawable.myimage);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值