[TextInputLayout] Focus between TextInputEditText and multiple fragments
See original GitHub issueDescription: I have 2 fragments. Xml are the same, contain 3 TextInputLayout.
When I am on Fragment2, I enter the text in fieldFour, I press enter on the keyboard, I expect the cursor to move to fieldFive, but it does not work. I think the cursor falls into the fields of Fragment1. How to fix this? I tried If to use EditTexts all cursor transitions work correctly.
If one fragment with the TextInputLayout set has been added. Cursor transitions from one TextInputLayout to another are performed correctly Thanks.
Source code:
supportFragmentManager.beginTransaction()
.add(R.id.frame, Fragment1())
.addToBackStack("Fragment1")
.commit()
supportFragmentManager.beginTransaction()
.add(R.id.frame, Fragment2())
.addToBackStack("Fragment2")
.commit()
xml Fragment1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="fragment1" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fieldOne"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fieldTwo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fieldThree"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
xml Fragment2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="fragment2" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fieldFour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fieldFive"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fieldSix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Android API version: API 29
Material Library version: I use 1.1.0, but there is also 1.2.0-alpha05
Device: Nokia 3.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
android - 2 hints appearing when TextInputLayout is focused
To solve the issue, just remove the FragmentTrancaction.replace from your main activity and let the Nav Component load up the fragment for you....
Read more >Android TextInputLayout Example | DigitalOcean
Android TexInputLayout extends LinearLayout. The primary use of a TextInputLayout is to act as a wrapper for EditText(or its descendant) and ...
Read more >TextInputLayout | Android Developers
Layout which wraps a TextInputEditText , EditText , or descendant to show a floating label when the hint is hidden while the user...
Read more >Material Design Edit Text | Android Studio Tutorial - YouTube
TextInputEditText - Material Design Edit Text | Android Studio Tutorial · Chapters. View all · Chapters · Description · Chapters. View all ·...
Read more >TextInputLayout not showing hint until focused [37048478]
When an EditText (or AppCompatEditText) is wrapped in a TextInputLayout, the hint does not show until the EditText is focused.
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
Hey there. Thanks for reporting.
Can you use something like
android:imeOptions="actionNext"
android:nextFocusForward="@+id/.."
to solve this?Great. Going to go ahead and close this.