question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextInputLayout] [Motion] Hint does not follow the layout in animations

See original GitHub issue

Description: I have some TextInputLayouts in a Fragment and I have set the Animation of my Fragments to MaterialFadeThrough. The Animation runs fine (slightly expanding in width), but the hint label inside the TextInputLayout does not move with the parent container. After tapping one Input, all hints in the view jump to the correct position.

Screenshots Before tapping (after enterTransition with MaterialFadeThrough): image

After focusing the first Input: image

Expected behavior: The hint should move correctly with the outline of the TextInputLayout.

Source code: Layout snippet

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/inputFirstName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="16dp"
        android:layout_marginTop="24dp"
        android:hint="@string/first_name">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPersonName" />

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

Style

    <style name="AppStyle.TextInput" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
        <item name="shapeAppearanceOverlay">?shapeAppearanceMediumComponent</item>
        <item name="materialThemeOverlay">@style/AppStyle.TextInput.Overlay</item>
        <item name="boxBackgroundColor">@color/cardBackground</item>
    </style>

    <style name="AppStyle.TextInput.Overlay" parent="ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox">
        <item name="editTextStyle">@style/AppStyle.EditText</item>
    </style>

    <style name="AppStyle.EditText" parent="Widget.MaterialComponents.TextInputEditText.FilledBox">
        <item name="android:background">@drawable/bg_textinput</item>
        <item name="android:textAppearance">@style/AppTextAppearance</item>
    </style>

Android API version: Android Q

Material Library version: Bug exists on 1.2.0-beta01 and 1.3.0-alpha01

Device: Android Emulator, Pixel 3 XL

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dsn5ftcommented, Jun 25, 2020

Ahh this keeps coming up, probably because it’s not very clear behavior from the Android Transitions framework. By default, when setting a transition on a fragment or a sceneRoot, that transition will be applied to each child view as opposed to the fragment as a whole. That behavior might make more sense for some of the framework transitions like Explode which expect to animate all the individual views, but our Material transition patterns typically expect to operate on screens as a whole.

I’m still not exactly sure why the TextInputLayout is behaving that way with a start icon, but you can workaround the issue and also achieve the intended effect by adding android:transitionGroup="true" to the top-level view of the fragment. If you support pre-lollipop, then you can do something like ViewGroupCompat.setTransitionGroup(fragment.getView(), true).

1reaction
dsn5ftcommented, Jun 18, 2020

Great, thank you! We’ll take a look soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextInputLayout disable animation - android - Stack Overflow
Looking into the source code of the TextInputLayout , I've discovered that the only occasion when the class doesn't update it's hint with...
Read more >
TextInputLayout | Android Developers
Returns whether the hint expands to occupy the input area when the text field is unpopulated and not focused. boolean, isHelperTextEnabled().
Read more >
TextInputLayout - Styling Android
The reason for this is that the position, colour, and size of the hint text will change as the EditText receives focus, so...
Read more >
Text fields - Material Design
If an EditText is being used, make sure to set its android:background to @null so that TextInputLayout can set the proper background on...
Read more >
Floating Labels In EditText TextInputLayout Android
TextInputLayout is a new element introduced in Design Support library to display the floating label in EditText. To display floating label in EditText, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found