我通過「資源選擇器」創建一個新的ImageButton
和我結束了這段代碼:如何在圖像變得模糊的情況下拉伸ImageButton?
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginLeft="14dp"
android:layout_marginTop="94dp"
android:src="@drawable/mybutton" />
現在,我想打那個按鈕的方式做大,所以我做了以下修改:
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginLeft="14dp"
android:layout_marginTop="94dp"
android:src="@drawable/aries" />
我也將android:src="@drawable/mybutton"
更改爲android:background="@drawable/mybutton"
,以擺脫我的圖像周圍的灰色按鈕,而不是拉伸圖像。
問題:
我的問題是,伸展出的圖像時,它仍然使用從drawable-mdpi
文件(因爲它應該),所以我結束了一個拉伸低分辨率圖像。如果我從drawable-mdpi
文件夾更改高分辨率文件夾的圖像,它看起來不錯,但我確信這不是最好的解決方案,因爲我必須在每個文件夾中放置分辨率更高的圖像。
我只是測試它。它很棒!謝謝! – 2014-09-10 14:54:27