I am using Button
in one of the layouts. I want Button
size to be as small as the text/label size.
I am using the following code.
<Button android:text="@string/cancle_button" android:id="@+id/button1" android:background="@drawable/back_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:textSize="12sp" android:textColor="#ffffff" android:textStyle="bold" />
But I want Button
height to be same as text/label height. Whenever I decrease or increase the text height, Button
height remains the same. How should I solve this problem?
You can achieve this by setting android:minHeight="0dp" for the Button widget. And I guess this behavior is because there is some default value (may be a 48dp) set for Button widgets by the framework considering a minimum touch area.
Solution 1: please use dimens. xml for specifying with and height for buttons. for tablet,please create folder values-sw600dp,values-sw720dp and put your dimens.
Using colors (background, text, border) Using custom shapes like circle, rounded corners and more. You can add images to your buttons to customize them. Using drawables to make gradients, dotted borders and more.
It's been almost a year since the question was asked. But I faced the problem now and got a solution. :) May be it will help someone.
You can achieve this by setting android:minHeight="0dp"
for the Button widget.
And I guess this behavior is because there is some default value (may be a 48dp) set for Button widgets by the framework considering a minimum touch area.
Use can take the image view in this case or if your taking text view in this case so you can take the image with proper size so that it would not bluer through these measures you can set small size for image Best way is you can take the image with that size you want to create its good way
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