2011-12-02 109 views
2

我有一個按鈕,我把一張圖片...我必須嘗試調整按鈕內的圖像...我如何調整它的大小?我可以直接從xml代碼執行嗎? 這是XML代碼:調整大小圖像按鈕

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/layout_root" 
     android:orientation="vertical" 
     android:layout_width="250dp" 
     android:layout_height="180dp" 
     android:paddingLeft="4dip" 
     android:paddingRight="4dip" 
     android:background="@color/white_trasparent" 
     android:weightSum="1"> 

    <TextView 
     android:layout_height="wrap_content" 
     android:id="@+id/text" 
     android:textColor="@color/grey" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_width="wrap_content" 
     android:layout_marginLeft="15dp"> 
     </TextView> 
    <Button 
     android:layout_width="wrap_content" 
     android:text="Drawable Top" 
     android:id="@+id/Button03" 
     android:drawableTop="@drawable/icon" 
     android:layout_height="wrap_content" 
     android:textSize="10dp"> 
     </Button> 
</LinearLayout> 

回答

0

如果我的drawableTop /左/下/右性質的理解是正確的,是不會把你的按鈕內你的形象,而它打算把它放在上面(北部)按鈕。

如果您要將圖像放入按鈕中,請檢查ImageButton

我不認爲這些東西中的任何一個都可以讓你只設置你的圖片的大小(雖然它們會讓你改變整個視圖的大小,在這種情況下矩形按鈕框和圖像內部它)。

爲了改變圖像的大小,而不會影響按鈕框圖形的大小,我認爲你必須縮小你的資源圖像在Photoshop中或其他東西。