2011-11-24 123 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

尝试使用按钮,并与空文本使其在这之后设置背景。

或:

使用图像按钮和把源和背景相同的图像获取按钮完全一样的图像


**你可以使用选择做出一些美容应用按钮 谷歌它很容易使用;)