Remove button text addition

I would like to remove the registration around the text in the Button view. The first screen shot is the result I would have achieved, and the second is the state of the art.

enter image description here

enter image description here

Of course, I defined a custom option to get the look of the button. But even if I set the padding attribute to 0dp, the result does not change.

Any suggestion please?

EDIT Here is the xml button code

<Button android:id="@+id/btnCancel" style="@style/dark_header_button" android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:includeFontPadding="false" android:padding="0dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:text="@android:string/cancel" /> 

Here is the xml style file:

 <style name="dark_header_button"> <item name="android:background">@drawable/bkg_dark_header_button</item> <item name="android:shadowDy">-1</item> <item name="android:shadowColor">#000000</item> <item name="android:shadowRadius">1</item> <item name="android:textSize">14sp</item> <item name="android:textColor">#ffffff</item> </style> 

and here is the pushed XML file:

 <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape> <corners android:radius="10dp" /> <gradient android:angle="90" android:endColor="#060606" android:startColor="#707070" android:type="linear" /> </shape> </item> <item> <shape> <corners android:radius="10dp" /> <gradient android:angle="90" android:endColor="#707070" android:startColor="#060606" android:type="linear" /> <stroke android:width="0.5dp" android:color="#2b2b2b" /> </shape> </item> </selector> 
+10
android android-button
07 Oct '13 at 14:04 on
source share
3 answers

The button text does not require filling, by default it is in the center of the button. I think you are using android:theme="@android:style/Theme.Black.NoTitleBar" in the manifest file, delete it and use the application’s native theme and try.

+1
07 Oct '13 at 14:19
source share

This is not really a padding, but the theme sets minHeight and minWidth for button widgets. You can completely remove this effect without changing the theme by setting the following in your button in xml:

 android:minHeight="0dp" android:minWidth="0dp" 

Thus, this also means that you can play with different settings for different effects, 0dp is just an example to completely remove this effect.

+37
Jul 28 '14 at 10:26
source share

you can try using android: includeFontPadding . set it to false. also set the fill value to 0.

+13
07 Oct '13 at 14:09
source share



All Articles