Drawable資源——Inset Drawable 可繪制插圖
1,認識 它可以将其他Drawable内嵌到自己當中,并可以在四周留出一定的間距。 當一個View希望自己的背景比自己實際區域小的時候,可以采用InsetDrawable來實作。 檔案位置 ︰
res/drawable/filename.xml
檔案名用作資源 id。
文法:
<?xml version="1.0" encoding="utf-8"?>
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/drawable_resource"
android:insetTop="dimension"
android:insetRight="dimension"
android:insetBottom="dimension"
android:insetLeft="dimension" />
2,各屬性注解
<inset>
xmlns:android
字元串。所需。定義 XML 命名空間,必須是
"http://schemas.android.com/apk/res/android".
android:drawable
可繪制資源。所需。要嵌入到某個可繪制的資源的引用。
android:insetTop
頂部内凹的大小。
android:insetRight
左邊内凹的大小。
android:insetBottom
底部内凹的大小。
android:insetLeft
右邊内凹的大小。
3,代碼示例
inset_srawable_useing.xml
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/icon"
android:insetLeft="10dp"
android:insetTop="10dp"
android:insetRight="10dp"
android:insetBottom="10dp" >
<shape android:shape="rectangle">
<solid android:color="#000000"/>
</shape>
</inset>