如何还原TextEditInputLayout来提示它们原来的位置?

时间:2018-10-22 20:31:08

标签: android android-layout android-fragments

我在注册页面(片段)上有多个TextEditInputLayouts,当我第一次打开它时,一切都很好。但是,当我在其下使用clear函数时,某些提示最终会出现在顶部,而某些提示最终会出现在行中。理想情况下,我希望视图看起来像原始视图一样,我不明白为什么当我在所有字段上调用相同的clear函数时,为什么一半视图的提示在顶部,而另一半视图的提示在行并且所有xml元素都完全相同(除了id / hint string / etc之外)。

有人知道这是为什么发生的,如何预防,或者至少在发生后如何解决?

相关XML

                        <android.support.design.widget.TextInputLayout
                            android:id="@+id/id_1"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:hint="@string/lbl_x"
                            android:theme="@style/themeX"
                            app:errorTextAppearance="@style/errorTheme">

                            <android.support.design.widget.TextInputEditText
                                android:id="@+id/input_1"
                                style="@style/editTextTheme"
                                android:imeOptions="actionNext"
                                android:inputType="textCapWords"
                                android:maxLines="1" />
                        </android.support.design.widget.TextInputLayout>

1 个答案:

答案 0 :(得分:0)

使用editText.setText(“”)代替null起作用。