androidandroid-textinputlayoutandroid-textinputedittext

No space for OutlinedBox TextInputLayout label


The outline for an OutlinedBox TextInputLayout doesnt leave a space for the hint/label:

enter image description here

<com.google.android.material.textfield.TextInputLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/edit_title_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Playlist Name"
    android:theme="@style/CustomTextInputLayout">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/edit_title_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLength="60"
        android:imeOptions="actionDone"
        android:inputType="text"
        />

</com.google.android.material.textfield.TextInputLayout>

<style name="CustomTextInputLayout" parent="@style/Widget.Material3.TextInputLayout.OutlinedBox">
    <item name="colorPrimary">@color/dialog_text_color</item>
    <item name="colorOnSurface">@color/dialog_text_color</item>
    <item name="android:padding">15dp</item>
</style>

The documentation says to set the android:hint.


Solution

  • The problem could stem from the padding added to TextInputLayout (15dp), which would interfere with the hint/label.

    You could also add padding to the first TextInputLayout in your code using android::paddingTop="15dp" (and/or paddingStart/paddingEnd) to make space for the label.