Android软键盘弹出将底部栏顶上去并不会挤压界面
16lz
2021-01-24
界面需要,找到了一种不需要去设置android:windowSoftInputMode属性的解决keyboard和layout不适问题
有关设置android:windowSoftInputMode的资料,可自行百度。
我的方法就是,将xml文件的根布局设置成ScrollView,将之前的布局嵌套在里面就行了,不需要去设置以上的任何属性
在中间没有控件显示的地方,使用view设置weight去占位置
下面给出我的xml布局
<ScrollView 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:fillViewport="true" tools:context="com.example.richedit.TestInputMethodActivity" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="40dp" android:background="#332423"> LinearLayout> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content"/> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="54dip" android:background="@android:drawable/bottom_bar"> <Button android:id="@+id/manual_setup" android:text="zuozuo" android:layout_height="wrap_content" android:layout_width="wrap_content" android:minWidth="100dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" /> <Button android:id="@+id/next" android:text="youyou" android:layout_height="wrap_content" android:layout_width="wrap_content" android:minWidth="100dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" /> RelativeLayout> LinearLayout>ScrollView>
这里给出keyb弹出时和没弹出时的效果图,很好的将底部栏顶了上去
转载于:https://www.cnblogs.com/robben/p/4832618.html
更多相关文章
- Android虚拟导航栏遮挡底部的输入框的解决方法
- 详解Android中获取SD卡和内存的空间信息
- [置顶] Android(安卓)中轴时光轴
- android 阻尼效果(图片下拉变大)
- Android(安卓)shape属性详细整理
- Android(安卓)Adapter适配器
- Android中TextView控件的singleLine废弃解决
- android ListView美化-->几个比较特别的属性
- Android移动应用开发基础2003291341