Android:默认情况下如何显示TextInputLayout的suffixText?

问题描述 投票:0回答:1

我正在使用最新版本的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>

When I am launching the Activity, I can't see suffix text of TextInputLayout

Only after clicking on TextInputEditText, I can see suffix text

请让我知道,默认情况下如何显示后缀文本。

android android-layout material-design android-textinputlayout android-textinputedittext
1个回答
0
投票

使用代码

inputLayout.suffixTextView.visibility = View.VISIBLE
inputLayout.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
    inputLayout.suffixTextView.visibility = View.VISIBLE
}
© www.soinside.com 2019 - 2024. All rights reserved.