2016-04-30 112 views
-1

我知道還有很多關於此的其他問題,但我嘗試了所有這些,沒有爲我工作。 我想創建一個帶有9個補丁背景的按鈕。這是我9修補圖像:9路徑不能正確拉伸

enter image description here

我創建這個在Android SDK中draw9patch.bat:

enter image description here

而且我用這個XML創建我的按鈕:

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="New Button" 
    android:id="@+id/btnTest" 
    android:background="@drawable/ic_btn2" /> 

但結果很奇怪:

enter image description here

爲了測試目的,我下載了一些9個補丁,並將它們替換爲我的圖像,但這些圖像也有這個問題。我使用android studio 2.導致這個問題的原因是什麼?

回答

2

確保文件名以.9.png結尾。

+0

謝謝,我錯過了那部分 –