[英]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:startIconDrawable
和app:endIconDrawable
而不是android:drawableStart
和android:drawableEnd
。
這兩個都進入您的TextInputLayout
而不是TextInputEditText
。
如需更多參考,請查看: https : //material.io/develop/android/components/text-fields
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.