【发布时间】:2020-07-09 13:21:24
【问题描述】:
所以我试图确保 TextInputEditText 中的主要文本(包裹在 TextInputLayout 中)垂直居中并使用默认的 Widget.MaterialComponents.TextInputLayout.FilledBox 样式,但是当提示被禁用时。
正如你在图片中看到的那样,app:hintEnabled="false",当前文本不是垂直居中的。
作为参考,我使用的是 1.1.0 版本的材料组件库。
我的布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/set_pos_password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:maxLength="4"
android:text="1111"
android:textAlignment="center" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
结果:
【问题讨论】:
标签: android android-textinputlayout material-components-android