In einer App, an der ich arbeite, habe ich mehrere ImageButtons. Jeder ImageButton hat einen Hintergrund und Inhalt in Form eines Drawables. Im Moment hat das Drawable die maximale Größe innerhalb der Grenzen des ImageButton, aber ich möchte, dass es verkleinert wird, also muss ich etwas Polsterung hinzufügen. Die Sache ist, dass wenn ich das versuche, es keine Wirkung hat. Mein XML ist wie folgt für jeden ImageButton:
<ImageButton
android:id="@+id/button_zero"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dip"
android:src="https://stackoverflow.com/questions/20545742/@drawable/button_zero"
android:background="@drawable/button_background" />
Irgendwelche Ideen, warum die Polsterung nichts tut?
Vollständiger XML-Code:
<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="https://stackoverflow.com/questions/20545742/@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>
Können Sie bitte Ihren gesamten XML-Code hinzufügen?
– Benutzer2235615
12. Dezember 2013 um 14:14 Uhr
@ user2235615 Ich habe die Frage aktualisiert 🙂
– Null
12. Dezember 2013 um 14:20 Uhr