需求:
注册页面,当点击任一输入框时,底部软键盘弹出,并一直在注册下方,看图效果

技术:
非全屏时:
adjustResize+ScrollView(EditText)+布局设置Bottom=软键盘在指定控件之上显示
全屏时:
adjustResize+ScrollView(EditText)+布局设置Bottom+ 布局根部(android:fitsSystemWindows=“true”)=软键盘在指定控件之上显示
实现:
1,在AndroidManifest.xml中的activity中设置android:windowSoftInputMode=“adjustResize”
2,直接贴上布局代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_pare

本文介绍了如何在Android应用中实现当软键盘弹出时,注册页面的EditText始终保持在软键盘上方。通过设置`android:windowSoftInputMode="adjustResize"`以及配合ScrollView和特定布局调整,无论应用是否全屏,都能达到预期效果。
最低0.47元/天 解锁文章
3551

被折叠的 条评论
为什么被折叠?



