2011-11-24 206 views
0

有人能解釋一下android如何使用圖像按鈕大小?我的按鈕看起來很奇怪。 我以下面的代碼爲例。我有兩個按鈕位於佈局的底部。這些按鈕共享寬度的50%,因爲它們並排放置。 在Abode PS中,兩個圖像(用於這兩個按鈕)實際上是2「x 38」或495x94像素。這個尺寸當然大於佈局中的可用空間。 我在按鈕上使用邊緣效果來給它們定義。 Android正在削減我的按鈕邊緣,以便在可用佈局空間中居中。 我正在處理的這個特定佈局只允許垂直方向,以防萬一。Android圖像按鈕佈局

謝謝。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
     android:id="@+id/layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" > 

     <ImageButton 
      android:id="@+id/ImageButton1" 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="1dip" 
      android:layout_marginRight="1dip" 
      android:layout_weight="1" 
      android:background="#FF000000" 
      android:src="@drawable/map4" > 
     </ImageButton> 


     <ImageButton 
      android:id="@+id/ImageButton3" 
      android:layout_width="0dip" 
      android:layout_marginRight="1dip" 
      android:layout_weight="1" 
      android:background="#FF000000" 
      android:src="@drawable/buy" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="1dip"> 
     </ImageButton> 
    </LinearLayout> 

</RelativeLayout> 

回答

0

嘗試使用按鈕,並與空文本使其在這之後設置背景。

或:

使用圖像按鈕和把源和背景相同的圖像獲取按鈕完全一樣的圖像


**你可以使用選擇做出一些美容應用按鈕 谷歌它很容易使用;)