为了账号安全,请及时绑定邮箱和手机立即绑定

启动片段并滚动时键盘打开

启动片段并滚动时键盘打开

qq_遁去的一_1 2023-12-13 10:10:55
我的片段中有一个滚动视图,当片段打开时,键盘会自动出现并专注于布局的第一个编辑文本,并且屏幕滚动,在键盘打开时我无法看到所有字段。那么,我该怎么做才能防止片段启动时出现键盘,以及如何在打开键盘的情况下查看滚动视图中的所有字段呢?谢谢这是 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">


查看完整回答
反对 回复 2023-12-13
  • 1 回答
  • 0 关注
  • 55 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信