我正在开发的应用中有几个ImageButton。每个ImageButton都有一个背景和以drawable形式呈现的内容。现在,这个drawable在ImageButton的限制范围内已经达到了最大尺寸,但是我希望它能缩小,所以我需要添加一些填充。问题是,当我尝试这样做时,它没有任何效果。每个ImageButton的XML如下:
<ImageButton
android:id="@+id/button_zero"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dip"
android:src="@drawable/button_zero"
android:background="@drawable/button_background" />
有什么想法,为什么填充(padding)不起作用?
完整的 XML 代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#222222"
tools:context=".Main" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Row One -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button_zero"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dip"
android:src="@drawable/button_zero"
android:background="@drawable/button_front" />
<ImageButton
android:id="@+id/button_one"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dip"
android:src="@drawable/button_one"
android:background="@drawable/button_front" />
<ImageButton
android:id="@+id/button_two"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dip"
android:src="@drawable/button_two"
android:background="@drawable/button_front" />
<ImageButton
android:id="@+id/button_three"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dip"
android:src="@drawable/button_three"
android:background="@drawable/button_front" />
<ImageButton
android:id="@+id/button_four"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dip"
android:src="@drawable/button_four"
android:background="@drawable/button_front" />
</LinearLayout>
... same for other rows
</LinearLayout>