use*_*675 3 android android-layout material-design android-textinputlayout android-textinputedittext
我正在使用最新版本的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>Run Code Online (Sandbox Code Playgroud)
请告诉我,如何默认显示后缀文本。
当文本字段为空时,您也可以用来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>
Run Code Online (Sandbox Code Playgroud)