Android 自定义 TextInput 布局,提示文本和占位符重叠

问题描述 投票:0回答:1

我在使用自定义 TextInputLayout 时遇到一个奇怪的问题,其中我同时具有提示文本和占位符文本,在一般情况下,当焦点位于编辑文本上时,提示文本会向上浮动,占位符文本会显示在编辑文本中,但在场景中,重点是编辑文本,应用程序进入后台,然后到达前台,然后提示文本和占位符文本重叠。

请参阅下图以供参考:

代码片段 XML 布局:

<com.deliverysdk.core.ui.ABCTextInputLayout

         android:id="@+id/et_mobile_input_layout"
         android:layout_width="match_parent"
         android:layout_height="56dp"
         android:layout_marginTop="16dp"
         android:clickable="true"
         android:focusable="true"              
   android:hint="@string/app_global_user_info_profile_mobile_num_txt"                  app:hintTextAppearance="@style/TextInputLayoutHintText"
         app:hintTextColor="@color/global_mine_shaft_600"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent"           
app:placeholderTextAppearance="@style/TextInputLayoutPlaceHolderText>

                    <com.deliverysdk.core.ui.GPEditText
                        android:id="@+id/et_mobile"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:imeOptions="actionSend"
                        android:importantForAutofill="no"
                        android:inputType="phone"
                        android:nextFocusDown="@id/et_email"
                        android:singleLine="true"
                        app:glb_et_error_text_view="@id/tv_phone_error"
                        app:glb_et_input_layout="@id/et_mobile_input_layout"
                        app:glb_et_prefix_color="@color/global_mine_shaft_500"
                        app:glb_et_type="clear_text" />

                </com.deliverysdk.core.ui.ABCTextInputLayout> 

有没有人遇到过同样的情况或者可以帮助我解决这个问题。 预先感谢。

android kotlin android-textinputlayout android-textinputedittext textinputlayout
1个回答
0
投票

通过在以编程方式设置 textinputlayout 上的占位符时添加延迟来解决此问题。

© www.soinside.com 2019 - 2024. All rights reserved.