Holo theme makes my button bigger

I have a little problem when applying a bare theme on devices with api> = version 11 My custom buttons get bigger (in height, the width seems to be the same)

It is without a hologram enter image description here

this is with their holon enter image description here

Can someone tell me what causes this? and if you can save the same button size as without a bare theme?

ps: this is my button:

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#F000" /> <stroke android:width="1px" android:color="#BB000000" /> <padding android:bottom="7dp" android:left="10dp" android:right="10dp" android:top="7dp" /> <corners android:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp" /> <gradient android:angle="90" android:centerColor="#5b5bcd" android:endColor="#6f6fcf" android:startColor="#4747e0" android:type="linear" /> </shape> 

and this is how I apply it on my button (i.e. in a linear gyrozonal linear ruler with a weight of 0.8)

 <Button android:id="@+id/addplayer" android:layout_width="0px" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="5dp" android:layout_weight="0.8" android:background="@drawable/blue_button_selector" android:text="Add player" /> 

Thank you!

+4
source share
2 answers

The Android Holo theme sets minWidth and minHeight in the styles.xml system file for Holo.Widget.Button, which defines rules in addition to those used by the non-bare button, Widget.Button. Even with a small button name, the button will occupy 64x48dip in Android 4.2.

 <Button android:id="@+id/sample_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Z" android:padding="6dp" android:minHeight="1dp" android:minWidth="1dp" android:layout_marginBottom="6dp" android:layout_marginRight="6dp" style="@style/CustomButton" android:textSize="16sp" /> 
+11
source
  • Make below xml files

  • You can apply a special theme in the manifest

Like this - android: theme = "@ style / NoActionBar"

[In the values ​​folder]

 <?xml version="1.0" encoding="utf-8"?> <resources> <style name="NoActionBar" parent="@android:style/Theme.Light.NoTitleBar"> <!-- Inherits the default theme for pre-HC (no action bar) --> </style> </resources> 

[In the values ​​folder-v11]

 <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="NoActionBar" parent="@android:style/Theme.Holo.Light.NoActionBar"> <!-- Inherits the Holo theme with no action bar; no other styles needed. --> <item name="android:buttonStyle">@style/CustomHoloLightButtonStyle</item> </style> <style name="CustomHoloLightButtonStyle" parent="@android:style/Widget.Holo.Light.Button"> <item name="android:minHeight">1dip</item> <item name="android:minWidth">1dip</item> </style> </resources> 
+6
source

Source: https://habr.com/ru/post/1479959/


All Articles