KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The following code is for displaying a custom button in Android. Unfortunately, all those padding values at those different places affect the way the button is rendered only for Android 2.3, but on Android 4.X it has no effect, i.e. the padding is always the same, regardless of what you set here. Why? The layout XML: <Button android:id="@+id/sample_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_caption" android:padding="6dp" android:layout_marginBottom="6dp" android:layout_marginRight="6dp" style="@style/CustomButton" android:textSize="16sp" /> The style: <style name="CustomButton"> <item name="android:layout_gravity">center_horizontal</item> <item name="android:padding">6dp</item> <item name="android:background">@drawable/custom_button</item> <item name="android:textColor">#ffffff</item> <item name="android:gravity">center</item> <item name="android:textStyle">bold</item> </style> The drawable: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape> <solid android:color="#60ff0000" /> <stroke android:width="1dp" android:color="#ffffff" /> <corners android:radius="4dp" /> <padding android:left="6dp" android:top="6dp" android:right="6dp" android:bottom="6dp" /> </shape> </item> <item> <shape> <solid android:col
Tags (comma-separated)
Save Edits
Cancel