material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[TextInputLayout] FilledBox floating hint cut off at start of suffix

Open holgerschlegel opened this issue 2 years ago • 3 comments

Description: Setup is a TextInputLayout with prefix, suffix and hint texts set. The contained TextInputEditText has a text set. Style is FilledBox. The floating label/hint is ellipsized at the end of the of the EditText instead of the end of the suffix text.

grafik

Not really sure if this is a bug or a feature request. I consider it a bug because the floating label is shown above the prefix but not above the suffix.

Expected behavior: The floating hint/label also uses the space above the suffix if needed.

Source code: The following XML is used in the layout to get what is seen in the screenshot.

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/text_input_layout_filled_normal"
        style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="16dp"
        android:hint="Longer Hint"
        app:layout_constraintEnd_toStartOf="@+id/guideline50"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/barrier_base_normal"
        app:prefixText="Pre"
        app:suffixText="Suf">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/text_input_text_filled_normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:imeOptions="actionNext"
            android:selectAllOnFocus="true"
            android:text="Text"
            android:textAlignment="center" />
    </com.google.android.material.textfield.TextInputLayout>

Android API version: 31

Material Library version: 1.6.1

Device: Android 10 in Emulator of Android Studio Chipmunk

holgerschlegel avatar Jul 02 '22 08:07 holgerschlegel

I think it's working as intended.

Can you elaborate why you think this is a bug and what should be the expected behavior?

Hint is independent from prefix, text, or suffix. I don't see a problem with ellipsizing hint solely?

drchen avatar Jul 06 '22 15:07 drchen

The hint should be independent from prefix and suffix. But why does the hint start above (in terms of y-axis) the prefix but does not continue above the suffix? That is at least inconsistent.

Another argument for extending the hint above the suffix is that for inputs for small numbers (up to 3 digits) there is nearly no space for the hint in the filled box style. The free space above the suffix could be used to the hint.

holgerschlegel avatar Jul 06 '22 17:07 holgerschlegel

ah ok. I got what you mean. I'll check how the label space is decided.

drchen avatar Jul 06 '22 17:07 drchen