我正在使用最新版本的 android Material 设计库 (1.2.0-alpha05)。我在 TextInputLayout 中添加了 app:suffixText="PlaceHolder"。我希望默认显示 suffixText,但目前,它仅在 TextInputLayout 获得焦点时可见。 当 TextInputLayout 失去焦点时,我看不到 suffixText。这是我的代码-:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:suffixText="PlaceHolder"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:hint="hint">
<com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
请告诉我,如何默认显示后缀文本。
最佳答案
您也可以使用 app:expandedHintEnabled="false"
在文本字段为空时显示后缀/前缀。
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:suffixText="...."
app:expandedHintEnabled="false"
>
<com.google.android.material.textfield.TextInputEditText
.../>
</com.google.android.material.textfield.TextInputLayout>
关于Android:如何默认显示TextInputLayout的suffixText?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60880048/