標籤:android style blog http color 使用
NinePatch能夠對.png圖片進行處理,產生一個.9.png格式的圖片,映像展開操作時,圖片就會有失真,而.9.png是Android裡所支援的一種特殊的圖片格式,可以實現部分展開。
製作圖片方法:
1、準備一張原始圖片
2、開啟..SDK/tools/draw9patch.bat
3、菜單File->open..開啟圖片
4、左邊是編輯區,右圖是預覽圖,在圖片外面的地區,單擊可畫黑線,按shift+單擊可擦除黑線,黑線的長度決定了展開的地區。
5、儲存.9圖,菜單:File->Save...輸入名字自動匯出.9.png格式的圖片(如果你的9.png中沒有黑線,eclipse是會報錯的)
使用:
android:background="@drawable/box"
執行個體:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:layout_width="100dp" android:layout_height="100dp" android:background="@drawable/box" /> <ImageView android:layout_width="200dp" android:layout_height="100dp" android:background="@drawable/box" /><ImageView android:layout_width="300dp" android:layout_height="200dp" android:background="@drawable/box" /></LinearLayout>
效果: