我的片段中有一個滾動視圖,當片段打開時,鍵盤會自動出現并專注于布局的第一個編輯文本,并且屏幕滾動,在鍵盤打開時我無法看到所有字段。那么,我該怎么做才能防止片段啟動時出現鍵盤,以及如何在打開鍵盤的情況下查看滾動視圖中的所有字段呢?謝謝這是 XML 的一部分<?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:id="@+id/personalDataLayout"android:layout_width="match_parent"android:layout_height="match_parent"android:focusable="true"android:focusableInTouchMode="true"tools:context=".presentation.fragments.PersonalDataFragment"><ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:padding="10dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
1 回答

喵喔喔
TA貢獻1735條經驗 獲得超5個贊
可聚焦的最高級別視圖將被聚焦。如果獲得焦點,EditTexts 會拉起鍵盤。但是如果你將以下內容添加到你的父View(RelativeLayout,LinearLayout等)中,那么鍵盤將不會自動打開
android:focusable="true"
android:focusableInTouchMode="true"
例子:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_height="match_parent">
添加回答
舉報
0/150
提交
取消