Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 文本框高度太高_Java_Android_Xml - Fatal编程技术网

Java 文本框高度太高

Java 文本框高度太高,java,android,xml,Java,Android,Xml,请看一下下面的XML布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vert

请看一下下面的XML布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
     >

    <TextView 
        android:id="@+id/lblPassword"
        android:text="@string/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

    <EditText
        android:id="@+id/pwdText"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:inputType="textPassword"
        />


    <Button 
        android:text="@string/btnLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="showMessage"
        />

</LinearLayout>

这将生成以下gui(附件)


如您所见,文本框的高度出乎意料地太高。实际上,我需要的是调整文本框的宽度以适合应用程序,提供足够的输入空间(如果我什么都不做,文本框的宽度看起来很小)。我是android新手。请帮忙

当你删除这一行时,它是否解决了问题
android:layout\u height=“0dp”


编辑:或将其更改为android:layout\u height=“wrap\u content”

不要对最外层布局的宽度或高度使用“匹配父级”属性。使用换行内容或填充父项。还可以将editText布局高度中的0dp替换为换行内容。

将editText更改为此

<EditText
        android:id="@+id/pwdText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:inputType="textPassword"
        />

要扩展宽度以匹配设备的宽度,请将
android:layout\u width=“wrap\u content”
替换为
android:layout\u width=“match\u parent”
,或者您可以在dp中指定宽度


通过设置属性
android:layout\u height=“0dp”
android:layout\u weight=“1”
表示希望此元素高度填充屏幕上的所有剩余空间。

对于文本视图高度,将其从换行内容更改为10 dp

非常感谢您的回复:)+1来自我