【发布时间】:2021-02-06 11:24:24
【问题描述】:
在https://material.io/components/text-fields 上有一个填充文本字段的交互式演示。 标签提示在输入字段内居中,当您单击它并输入一些文本时,标签会向上移动并且您输入的文本略低于中心(低于先前提示的位置)
问题是我无法在 Android 上重现此行为,因为我输入的文本与占位符保持在同一位置。
代码:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_password"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_marginTop="16dp"
android:background="@drawable/edittext_bg"
android:hint="@string/password"
app:boxStrokeWidth="1dp"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/tiet_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:inputType="textPassword"
android:textSize="17sp" />
</com.google.android.material.textfield.TextInputLayout>
【问题讨论】:
标签: android material-design material-components-android android-textinputlayout android-textinputedittext