android - TextInputLayout 为某些设备自动隐藏

标签 android android-layout android-textinputlayout

我添加了 7+ TextInpuLayout 和父级 ScrollView 并且 TextInputLayout 在某些设备上只显示第一个后隐藏并且对于某些设备它工作得很好。 为了更好地理解,这里有两个屏幕截图

适用于少数设备 enter image description here

but hides automatically like this

但是这样会自动隐藏

我正在使用 实现 'com.android.support:design:26.1.0' 用于设计库。

这是布局文件

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="true"
    android:orientation="vertical"
    android:scrollbars="vertical"
    tools:context="clockworktt.gaby.com.GuestProfileActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <include
            android:id="@+id/guest_profile_toolbar"
            layout="@layout/app_bar_layout"></include>

    </android.support.design.widget.AppBarLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:layout_marginTop="?android:attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:gravity="center"
        android:orientation="vertical">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/guest_profile_image"
            android:layout_width="90dp"
            android:layout_height="90dp"
            android:src="@drawable/ic_avatar" />

        <TextView
            android:id="@+id/guest_profile_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="Guest Name"
            android:textAlignment="center"
            android:textColor="@color/almostWhite"
            android:textSize="18sp" />

    </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="210dp"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/profile_name_input_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Name"
                    android:paddingLeft="10dp"
                    android:singleLine="true"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="14sp" />
            </android.support.design.widget.TextInputLayout>



            <android.support.design.widget.TextInputLayout
                android:id="@+id/profile_salutation_input_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Salutation"
                    android:paddingLeft="10dp"
                    android:singleLine="true"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="14sp" />
            </android.support.design.widget.TextInputLayout>



            <android.support.design.widget.TextInputLayout
                android:id="@+id/profile_email"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Email"
                    android:inputType="textEmailAddress"
                    android:paddingLeft="10dp"
                    android:singleLine="true"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="14sp" />
            </android.support.design.widget.TextInputLayout>



                <android.support.design.widget.TextInputLayout
                    android:id="@+id/profile_occupation"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    >

                    <android.support.design.widget.TextInputEditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Occupation"
                        android:paddingLeft="10dp"
                        android:singleLine="true"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="14sp" />
                </android.support.design.widget.TextInputLayout>

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/profile_company"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp">

                    <android.support.design.widget.TextInputEditText
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Company"
                        android:paddingLeft="10dp"
                        android:singleLine="true"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="14sp" />
                </android.support.design.widget.TextInputLayout>




            <android.support.design.widget.TextInputLayout
                android:id="@+id/profile_phone"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Phone"
                    android:inputType="numberDecimal"
                    android:paddingLeft="10dp"
                    android:singleLine="true"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="14sp" />

            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/profile_expected_numbers"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Expected Numbers"
                    android:inputType="phone"
                    android:paddingLeft="10dp"
                    android:singleLine="true"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="14sp" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/profile_notes"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <android.support.design.widget.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:hint="Notes"
                    android:inputType="textShortMessage"
                    android:maxLines="3"
                    android:paddingLeft="10dp"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="14sp" />
            </android.support.design.widget.TextInputLayout>


            <Button
                android:id="@+id/profile_update_button"
                android:layout_width="match_parent"
                android:layout_alignParentBottom="true"
                android:layout_height="wrap_content"
                android:text="Update"
                android:background="@color/colorAccent"
                android:textAllCaps="false"
                android:textColor="@color/almostWhite"/>

        </LinearLayout>



    </RelativeLayout>

</ScrollView>

请有人帮忙。谢谢

最佳答案

尝试将 TextInputLayout 的 layout_height 属性设置为 wrap_content

关于android - TextInputLayout 为某些设备自动隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48632424/

相关文章:

java - 如何创建一个新的 Bundle 对象?

android - 如何在android中找到距折线的距离?

android - 面向 fragment 的架构和后台堆栈

android - 更改android应用程序的基本主题颜色

android - Jetpack 撰写 : Disable Interaction with TextField

android - 在整个应用程序中设置旋转

android - 一个屏幕上的两个图形

android - 如何让 wrap_content TextView 停留在 ConstraintLayout 上 Button 的左侧?

android - 自定义文本输入布局

android - 如何修复 "TextInputLaout with TextInputEditText view I can not implement to show next focus Edittext using imeOption and nextFocustDown attribute"