简体   繁体   中英

EditText lose focus when the soft keyboard is displayed in Android Nougat

In Android Nougat, the EditText loses focus when the keyboard is displayed. This is working fine with all the lower versions.

I am using requestFocus() manually to get the focus to the EditText and programmatically showing the keyboard. The EditText is placed inside a ListView .

Could someone help me to resolve the issue?

If you can replace ListView with RecyclierView easily, that would be my suggestion. It worked for me.

Try:

  1. Add android:descendantFocusability="afterDescendants" to your ListView .

  2. Add android:focusable="true" and android:focusableInTouchMode="true" to your EditText .

  3. Add android:windowSoftInputMode="adjustPan" to your Activity in AndroidManifest file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM