如果我将 EditText 聚焦在 ScrollView 中,则会发生这种情况(很好):
然后,我关注下面的 EditText 并从图片一中重新关注 EditText,然后发生这种情况:
提示未显示或显示不正确(取决于滚动视图)。
解决方案的一部分: Scrollview 看到我想关注 EditText 而不是包围的 android.support.design.widget.TextInputLayout 元素。因此,它不关心是否正在显示提示。
怎么修?我的 XML(基本上是一个带有一些线性布局的滚动视图,其中包含带有 EditTexts 的 android.support.design.widget.TextInputLayout):
<ScrollView
android:layout_width="match_parent"
android:fadeScrollbars="false"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:weightSum="9"
android:descendantFocusability="beforeDescendants"
android:layout_height="match_parent">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="1"
android:gravity="center"
android:layout_height="match_parent" />
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<EditText
android:layout_width="match_parent"
android:layout_weight="1"
android:maxLines="1"
android:hint="hint1.1"
android:inputType="numberDecimal"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<EditText
android:layout_width="match_parent"
android:maxLines="1"
android:inputType="number"
android:hint="hint1.2"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="9"
android:layout_height="match_parent">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="2"
android:gravity="center"/>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<EditText
android:layout_width="match_parent"
android:layout_weight="1"
android:maxLines="1"
android:hint="hint2.1"
android:inputType="numberDecimal"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<EditText
android:layout_width="match_parent"
android:layout_weight="1"
android:maxLines="1"
android:hint="hint2.2"
android:inputType="number"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="9"
android:layout_height="match_parent">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="3"/>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<EditText
android:layout_width="match_parent"
android:hint="hint3.1"
android:maxLines="1"
android:inputType="numberDecimal"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<EditText
android:layout_width="match_parent"
android:layout_weight="1"
android:hint="hint3.2"
android:maxLines="1"
android:inputType="number"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>