I'm trying to padd my button background image of my main menu (I'm using a selector for the different states), doing it on this way (buttoninicio_custom.xml):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/botoninicial_pressed"
android:state_pressed="true">
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</item>
<item android:drawable="@drawable/botoninicial_pressed"
android:state_focused="true">
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</item>
<item android:drawable="@drawable/botoninicial">
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</item>
</selector>
..but the padding has no effect. What I should do to solve this problem??
I already used "bitmap" tag inside each "item" tag with the padding inside, but it's still doing anything!!!
My main button looks this way:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="@+id/button2"
android:layout_width="180dp"
android:layout_height="50dp"
android:layout_marginBottom="15dp"
android:textSize="16sp"
android:textColor="#FFFFFF"
android:background="@drawable/buttoninicio_custom"
android:text="@string/idmMENU2" />
</LinearLayout>
"Because if I set android:padding inside the "button" tag, it pads me the text not the background image... The problem it's that when I pressed the main button: My image background change correctly but the new image appear cut."
Wrap it in a layer-list
:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="3dp"
android:left="3dp"
android:right="3dp"
android:top="1dp">
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- your original selector content -->
</selector>
</item>
</layer-list>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With