【问题标题】:How can I change the height of a EditText and a Button?如何更改 EditText 和 Button 的高度?
【发布时间】:2011-05-07 22:40:59
【问题描述】:

我有这个EditText 和Button,我必须降低它的高度。我尝试使用android:height="10px",但它不起作用。顺便说一句android:width="180px" 工作正常,然后我不知道为什么我不能调整高度。

代码如下:

<EditText 
    android:id="@+id/Movile"
    android:layout_alignBaseline="@+id/MovileLabel"
    android:layout_alignParentRight="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:width="180px"
    android:height="10px"/>

<Button
        android:id="@+id/inviteButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/invite"
        android:width="100px"
        android:height="5px"
        android:layout_marginLeft="40dip"/>

【问题讨论】:

标签: android height android-edittext


【解决方案1】:

不要将值设置为android:height="10px",而是使用android:layout_height="10px"

 android:layout_width="180px"
 android:layout_height="10px"

【讨论】:

  • 您是否在 EditText 和 Button 中都进行了编辑?你的父布局是哪个?
【解决方案2】:

使用android:minHeight="120dp" 属性。

如果需要动态增加高度添加 android:layout_height="wrap_content"

【讨论】:

    【解决方案3】:

    您需要摆脱 "wrap_content" 属性,只保留固定的宽度和高度:

    <EditText 
        android:id="@+id/Movile"
        android:layout_alignBaseline="@+id/MovileLabel"
        android:layout_alignParentRight="true"
        android:layout_width="180px"
        android:layout_height="10px"/>
    
    <Button
            android:id="@+id/inviteButton"
            android:text="@string/invite"
            android:layout_width="100px"
            android:layout_height="5px"
            android:layout_marginLeft="40dip"/>
    

    【讨论】:

      【解决方案4】:

      如果里面的字体太大,你不能减小 TextEdit 的大小。

      试试android:textSize='6sp'

      【讨论】:

      • 你试过上面的代码和 android:layout_height="wrap_content" 吗?
      猜你喜欢
      • 1970-01-01
      • 2011-03-31
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多