Exposed Dropdown Menu TextInputLayout hint overlaps text
See original GitHub issueAfter following the sample for setting up an exposed dropdown menu, it appears that the hint text always overlaps the text for the selected item. Also I have to add padding to the AutoCompleteTextView otherwise the text and hint are completely aligned to the start of the TextInputLayout.
<androidx.constraintlayout.widget.ConstraintLayout
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="wrap_content">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/dropdown"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:hint="hint"
app:helperText="helper"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<AutoCompleteTextView
android:id="@+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:text="item"
android:editable="false" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Android API version: 28
Material Library version: 1.1.0-alpha08
Device: Samsung S8
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:11 (2 by maintainers)
Top Results From Across the Web
TextInputLayout with OutlinedBox stroke overlaps the hint
I use com.google.android.material:material:1.1.0 and trying to make EditText ...
Read more >Creating & styling dropdown menus on Android - ITNEXT
Exposed dropdown menus display the currently selected menu item ... so that it doesn't overlap with the background of our TextInputLayout.
Read more >Exposed Drop-Down Menu in Android | by Emine İNAN
You can put a title in your Exposed Drop-Down Menu with hint property in TextInputLayout. You can put an icon in your Exposed...
Read more >Textinputlayout With Outlinedbox Stroke Overlaps ... - ADocLib
Description: When using the Widget.MaterialComponents.TextInputLayout.OutlinedBox style the error text overlaps with the outline box: image. Expected. Change to ...
Read more >TextInputLayout label overlapping ... - appsloveworld
Coding example for the question TextInputLayout label overlapping AppCompatAutoCompleteTextView input-kotlin. ... ExposedDropdownMenu" android:hint="Hint" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@VGJohn Did you try giving the
AutoCompleteTextView
a style? Seem likestyle="@style/Widget.MaterialComponents.AutoCompleteTextView.FilledBox"
solves your problem even without the nice workaround provided above.Using
Theme.MaterialComponents.Light
on this activity this gives me@VGJohn @cgoodroe Had the same issue here, running library version 1.1.0-alpha10 on an HTC device. After taking a look at the source code the issue seems to be caused by
calculateLabelMarginTop()
inside TextInputLayout.java on line 1836: https://github.com/material-components/material-components-android/blob/7bb525ff591eca829fabe002e127671843abe122/lib/java/com/google/android/material/textfield/TextInputLayout.java#L1836Apparently the margin calculation in not implemented for the Filled Box menu type!!! Which is surprisingly what we are using in our case! So armed with this knowledge here’s a workaround:
app:boxBackgroundMode="outline"
app:boxStrokeWidth="0dp"
Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu
for the style of InputLayout with desired customizations.This helps to get the top margin calculation working but mimicking the filled box type by removing the border.