gpt4 book ai didi

android - 如何防止软键盘只上推工具栏?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:35:58 25 4
gpt4 key购买 nike

我有一个布局,顶部有一个工具栏和几个 EditText View :

<RelativeLayout
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.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</android.support.v7.widget.Toolbar>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/my_toolbar">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edit_text1"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edit_text2"/>

...

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edit_text7"/>
</LinearLayout>

</RelativeLayout>

当靠近屏幕底部的一些EditText打开软键盘时,整个屏幕(包括工具栏)将被向上推。有什么方法可以让软键盘上推整个屏幕,除了工具栏(修复工具栏)?

一些现有的answers实际上可以固定整个屏幕,但是靠近底部的EditText也可能被软键盘挡住。

谁能给我一个好的解决方案?

最佳答案

将 android:fitsSystemWindows="true"放在第一个相对布局中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
....
....
</RelativeLayout>

并在 list 中添加这个

android:windowSoftInputMode="adjustPan"

关于android - 如何防止软键盘只上推工具栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34351274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com