按钮在线性布局中不可见

时间:2019-11-15 19:39:01

标签: android android-studio android-layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_margin="10dp"
    tools:context=".LoginActivity">

    <EditText
        android:id="@+id/etUsername"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Username"
        android:inputType="textEmailAddress" />

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password" />

    </com.google.android.material.textfield.TextInputLayout>

    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Where is my button" />

</LinearLayout>

这是XML文件,我在任何地方都看不到我的按钮?这是为什么? 按钮发生了什么问题,我做错了什么?我想念什么?该按钮未在设计中显示。 谢谢

1 个答案:

答案 0 :(得分:2)

您将com.google.android.material.textfield.TextInputLayout的{​​{1}}设置为layout_height。这就是为什么您看不到match_parent的原因。像下面这样将button设置为layout_height

wrap_content
相关问题