I designed coloured Android Button Drawables and put them in a TableLayout. The problem is that Android's default buttons do not take up the entire cell space, but my drawables do (See attatched pictures). How can I adjust my XML so that my drawables leave a bit of space like the default buttons? I've pasted the XML code at the bottom.
Custom Buttons:
Default Buttons:
XML CODE:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><shape>
<gradient android:angle="90" android:endColor="@color/dark_red" android:startColor="@color/brick_red" />
<corners android:radius="10dip" />
<padding android:bottom="10dip" android:left="10dip" android:right="10dip" android:top="10dip"></padding>
</shape></item>
<item android:state_focused="true"><shape>
<gradient android:angle="270" android:endColor="@color/dark_red" android:startColor="@color/brick_red" />
<corners android:radius="10dip" />
<padding android:bottom="10dip" android:left="10dip" android:right="10dip" android:top="10dip" />
</shape></item>
<item><shape>
<gradient android:angle="270" android:endColor="@color/dark_red" android:startColor="@color/red" />
<corners android:radius="10dip" />
<padding android:bottom="5dip" android:left="5dip" android:right="5dip" android:top="5dip" />
</shape></item>
</selector>
Thanks for your help :)
Did you try to use the Top, Left, Bottom and Right attributes of items ? See : How to add padding to gradient <shape> in Android?
Alternatively, in your final layout that uses the button, you could use the attribute :
android:layout_margin(Right,Left,Top,Bottom)