XML Bitmap 是一個用XML定義的文件放在資源目錄,定義的對象是圖片,爲bitmap定義別名,這個文件能夠給bitmap定義一些額外的屬性。例如:抖動。html
文件存放位置:
res/drawable/filename.xmlandroid
語法:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@[package:]drawable/drawable_resource"
android:antialias=["true" | "false"]
android:dither=["true" | "false"]
android:filter=["true" | "false"]
android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
"fill_vertical" | "center_horizontal" | "fill_horizontal" |
"center" | "fill" | "clip_vertical" | "clip_horizontal"]
android:tileMode=["disabled" | "clamp" | "repeat" | "mirror"] />spa
例子:
[html]
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<!-- 與默認狀況(@drawable/btn_default_pressed_holo_light)有差異 -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/bm"
android:text="sssssssssssssssssss" />
</RelativeLayout> xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<!-- 與默認狀況(@drawable/btn_default_pressed_holo_light)有差異 -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/bm"
android:text="sssssssssssssssssss" />htm
</RelativeLayout>
效果圖:對象
默認(@drawable/btn_default_pressed_holo_light):圖片
引用(
@drawable/bm):ip
從截圖上就能夠看出來差異。utf-8
titileMode="repeat":資源