Closed nibarius closed 2 years ago
Trying to work around this issue by using a RelativeLayout or a LinearLayout instead of a ConstraintLayout shows a different, but somewhat similar problem. If the placeholder text is shorter than the title / message of the dialog everything works fine, but if the placeholder text is longer than the title the TextInputLayout becomes high enough to fit two lines of text. Not sure if it's the same issue or something that's better to report as a separate issue.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingHorizontal="16dp">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:hint="TextInputLayout"
app:expandedHintEnabled="false"
app:placeholderText="placeholder text is longer than the title">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="false" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
Is this still an issue with the latest library version? I copied your code without any modification and I cannot really reproduce it.
If it's still reproducible, can you provide a minimum reproducible sample for us to debug? Thanks!
I can reproduce the issue in version 1.5.0 but not in 1.7.0-alpha01 so it's seems to have been fixed recently.
Awesome! Thanks for the confirmation. I'll close the issue. : )
Description: Using a TextInputLayout with
app:expandedHintEnabled="false"
works fine in a normal fragment, but when using it in a DialogFragment using ConstraintLayout the height of the TextInputLayout becomes larger the longer the placeholder text is. When using a 1 character placeholder text the height is correct, when the placeholder text length is 2 the height is enough for 2 lines of text, with a length of three the height is suitable for 3 lines and so on.For this to reproduce the layout_width has to be set to 0dp. If using a fixed width,
match_parent
orwrap_content
it does not reproduce.Expected behavior: The height of the TextInputLayout should be suitable for one line of text when the placeholder text is short enough to fit on one line.
Source code: Dialog fragment class:
Creating the dialog:
dialog_text.xml:
Android API version: 30
Material Library version: 1.4.0 and 1.5.0-alpha01
Device: Pixel 5 and x86_64 emulator
To help us triage faster, please check to make sure you are using the latest version of the library.
We also happily accept pull requests.