Android工具:延展圖片NinePatch

來源:互聯網
上載者:User

標籤: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>

效果:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.