我添加了7+ TextInpuLayout与父ScrollView和TextInputLayout隐藏后只显示某些设备的第一个和一些设备它工作得很好。 这里有两个截图,以便更好地理解
但会像这样自动隐藏
我正在使用implementation '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>
请有人帮忙。谢谢
答案 0 :(得分:1)
尝试将TextInputLayout的 layout_height 属性设置为 wrap_content 。