Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change width and height of 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'm unable to change width and height of a Button. What's the problem?

like image 515
user1012116 Avatar asked Oct 31 '11 06:10

user1012116


1 Answers

Its wrong to use

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

Instead of it, give 100dp to layout_width and 20dp to layout_height and remove the width and height attributes.

Such as,

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>
like image 59
Paresh Mayani Avatar answered Nov 15 '22 07:11

Paresh Mayani