我遇到了一個問題,即我的 TextInputLayout 標簽與 AppCompatAutoCompleteTextView 中的輸入重疊。如果之前已經回答過,我深表歉意。這是我的代碼片段:
<com.google.android.material.textfield.TextInputLayout
android:id="@ id/commission_form_category_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@ id/commission_form_category_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/commission_form_category_label_text"
android:paddingHorizontal="16dp"
android:paddingVertical="16dp"
android:text="Hello"
android:singleLine="true"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
這是它的樣子: 重疊文本
uj5u.com熱心網友回復:
嘗試這個-
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Example">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
style="@style/Widget.MaterialComponents.AutoCompleteTextView.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello" />
</com.google.android.material.textfield.TextInputLayout>
uj5u.com熱心網友回復:
將 androidx.appcompat.widget.AppCompatAutoCompleteTextView 更改為 com.google.android.material.textfield.MaterialAutoCompleteTextView 并將樣式添加到 TextInputLayout
這是它的外觀
<com.google.android.material.textfield.TextInputLayout
android:id="@ id/commission_form_category_container"
android:layout_width="match_parent"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:hint="Hint"
android:layout_height="wrap_content">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@ id/commission_form_category_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello"
android:singleLine="true"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
uj5u.com熱心網友回復:
代替 paddingVertical 和 paddingHorizo??ntal 您可以通過指定填充
填充頂部
填充開始
paddingEnd
paddingBottom
<com.google.android.material.textfield.TextInputLayout android:id="@ id/commission_form_category_container" android:layout_width="match_parent" android:layout_height="wrap_content"> <androidx.appcompat.widget.AppCompatAutoCompleteTextView android:id="@ id/commission_form_category_input" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/commission_form_category_label_text" android:paddingTop="24dp" android:paddingBottom="8dp" android:paddingStart="16dp" android:paddingEnd="16dp" android:text="Hello" android:singleLine="true" android:textSize="16sp" /></com.google.android.material.textfield.TextInputLayout>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/438434.html
上一篇:使用游標讀取資料庫時出錯
