So I am trying to ensure that the main text in a TextInputEditText
(wrapped in a TextInputLayout
) is vertically centered with the default Widget.MaterialComponents.TextInputLayout.FilledBox
style but when the hint is disabled.
As you can see in the image, with app:hintEnabled="false"
, the current text is not vertically centred.
For reference I am using the 1.1.0 version of the material components library.
My layout file:
<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>
The result: