How to change the width and height of a button in Android

<Button android:text="Layer 1" android:layout_width="wrap_content" android:id="@+id/button1" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginLeft="10dp" android:layout_marginTop="50dp" android:width="100dp" android:height="20dp"> </Button> 

I can not change the width and height of the button. What is the problem?

+6
source share
1 answer

Misuse

 android:width="100dp" android:height="20dp" 

Instead, give 100dp for layout_width and 20dp in layout_height and remove the width and height attributes.

For instance,

 android:layout_height="100dp" android:layout_width="20dp" 

Update:

 <Button android:text="Layer 1" android:layout_width="100dp" android:id="@+id/button1" android:layout_height="20dp" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginLeft="10dp" android:layout_marginTop="50dp"> </Button> 
+19
source

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


All Articles