我正在使用最新版本的android材质设计库(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>
请让我知道,默认情况下如何显示后缀文本。
使用代码
inputLayout.suffixTextView.visibility = View.VISIBLE
inputLayout.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
inputLayout.suffixTextView.visibility = View.VISIBLE
}