3

I use com.google.android.material:material:1.1.0 and trying to make EditText with outlined box with a hint. My issue is that stroke of the box is overlaps the hint: enter image description here

Here is my code:

    <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:boxStrokeWidth="1dp"
        app:hintEnabled="true">

        <androidx.appcompat.widget.AppCompatAutoCompleteTextView
            android:id="@+id/export_csv_sep_edit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:minWidth="130dp"
            android:layout_gravity="bottom"
            android:digits=",;:.|/*-_"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:imeOptions="actionDone|flagNoFullscreen|flagNoExtractUi"
            android:inputType="text"
            android:maxLength="1"
            android:maxLines="1"
            android:selectAllOnFocus="true"
            android:singleLine="true"
            android:text=","
            android:hint="@string/separator"
            android:textColor="?android:textColorPrimary"
            android:textSize="@dimen/normal_font_size"
            android:completionThreshold="1"/>

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

Is it bug in the material library, or something wrong with my code?

Oleksandr Albul
  • 1,611
  • 1
  • 23
  • 31

2 Answers2

1

It seems there are quite some bugs with version 1.1.0

For now they have addressed some in the latest release, update your version to latest one (see latest releases here)

For now latest release is : 1.2.0-alpha06

Or use below in your app gradle :
implementation 'com.google.android.material:material:1.2.0-alpha06

Refer here for issues reported for material components or you can raise one yourselves

shadygoneinsane
  • 2,226
  • 1
  • 24
  • 47
1

It depends by the use of android:gravity="center"

<androidx.appcompat.widget.AppCompatAutoCompleteTextView
   android:gravity="center"
   ..>

Starting from 1.2.0-alpha02 the bug is fixed and there is a different behavior.

In any case use MaterialAutoCompleteTextView or AutoCompleteTextView instead of androidx.appcompat.widget.AppCompatAutoCompleteTextView (there is an auto-inflation of MaterialAutoCompleteTextView using AutoCompleteTextView).

Something like:

<com.google.android.material.textfield.TextInputLayout
    ...
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">

    <AutoCompleteTextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        .....
    />

</com.google.android.material.textfield.TextInputLayout>
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841