In un'applicazione a cui sto lavorando, ho diversi ImageButtons. Ogni ImageButton ha uno sfondo e un contenuto sotto forma di drawable. In questo momento il drawable ha le dimensioni massime entro i confini di ImageButton, ma voglio ridimensionarlo, quindi ho bisogno di aggiungere del padding. Il fatto è che quando provo a farlo, non ha alcun effetto. Il mio XML è il seguente per ogni ImageButton:Padding non funziona su 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="@drawable/button_zero"
android:background="@drawable/button_background" />
Qualche motivo per cui l'imbottitura non fa nulla?
codice XML completa:
<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>
Può cortesemente aggiungere tutto il codice XML? – user2235615
@ user2235615 Ho aggiornato la domanda :) – Zero