解决进入Activity默认焦点选中第一个EditText,并弹出软键盘。

解决方法:在xml的根容器中添加两个配置即可:将 focusable 和 focusableInTouchMode 都设为 true 即可。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:focusable="true"
    android:focusableInTouchMode="true">

</LinearLayout>
 ———————————————— 
版权声明:本文为CSDN博主「violet-jack」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/violetjack0808/article/details/78599738

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章