BitmapDrawable 使用
目录
BitmapDrawable 使用举例
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="true"
android:filter="true"
android:gravity="center"
android:mipMap="true"
android:src="@drawable/ic_launcher"
android:tileMode="disabled">
</bitmap>
属性详解
android:antialias=”true” 是否开启图片抗锯齿功能。开启后图片变得平滑。会一定程度降低图片的清晰度,一般开启。
android:filter=”true” 是否开启过滤效果。当图片尺寸被拉伸或者压缩时,开启过滤效果可以保持较好的显示效果,一般开启。
android:gravity=”center” 当图片小于容器的尺寸时,设置此选项可以对图片进行定位。
android:mipMap=”true” 纹理映射,系统默认为false,不常用,可忽略。
android:src=”@drawable/ic_launcher” 图片资源Id
android:tileMode=”disabled” 平铺模式。默认disabled ,启用tileMode时gravity属性会被忽略掉。
disabled 关闭平铺模式,系统默认选项,
clamp 图片四周的像素会扩展到周围区域
repeat 表示简单的水平和竖直方向上的平铺效果。
mirror 表示水平和竖直方向上的镜面投影效果。
本文详细介绍了BitmapDrawable的使用方法,包括如何定义BitmapDrawable及其属性的作用。通过XML示例讲解了抗锯齿、过滤效果、图片定位等关键属性,并解释了平铺模式的不同选项。

625

被折叠的 条评论
为什么被折叠?



