简体   繁体   English

如何在Android中更改Button的宽度和高度

[英]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. 我无法改变Button的宽度和高度。 What's the problem? 有什么问题?

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. 而不是它,给layout_height赋予100dp layout_width和20dp,并删除width和height属性。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM