繁体   English   中英

奇怪的 TextInputLayout 行为

[英]Strange TextInputLayout behavior

我试图在我的 textinputlayout 中显示一个可绘制的结束。 然而,drawable 以一种不需要的方式覆盖了 textinputlayout 的背景(参见图片Drawable 阻碍了背景)。

使用轮廓样式时会发生相同的行为。 后缀的行为方式相同时会出现另一个问题(请参阅图像后缀问题)。

此外,错误图标是隐藏的,直到 textinputlayout 的编辑文本中有文本(参见图像No error icon , Error icon )。 错误图标也显示同样奇怪的视觉行为。

这是我的 textinputlayout 的样子:

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/locationTVLayout"
                style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hapticFeedbackEnabled="true"
                android:hint="Where?"
                app:endIconContentDescription="Find my location."
                app:endIconDrawable="@drawable/ic_baseline_location_searching_24"
                app:endIconMode="custom"
                app:endIconTint="@color/colorAccent"
                app:errorEnabled="true"

                app:startIconDrawable="@drawable/ic_baseline_location_on_24">


                <AutoCompleteTextView
                    android:id="@+id/locationTV"
                    style="@style/Widget.MaterialComponents.AutoCompleteTextView.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:completionThreshold="1"
                    android:layout_below="@id/tempInputTV"
                    android:nextFocusForward="@+id/tempInputTV"
                    android:selectAllOnFocus="true"
                    android:singleLine="true"

                    />
            </com.google.android.material.textfield.TextInputLayout>

我的 Material gradle 参考是:

api 'com.google.android.material:material:1.3.0-alpha02'

使用app:startIconDrawableapp:endIconDrawable而不是android:drawableStartandroid:drawableEnd

这两个都进入您的TextInputLayout而不是TextInputEditText

如需更多参考,请查看: https : //material.io/develop/android/components/text-fields

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM