.1.需求:“自定义标题栏不动,多编辑框界面能保持上移输入时可见”
问题表现:
manifest文件中activity注册声明没有该属性时或者设置该属性如下adjustPan
:
android:windowSoftInputMode="adjustPan"
表现为整个布局被上移,很多时候布局文件里面自定义的标题也会被推出屏幕之外,面对常有的自定义标题栏十分难堪。
有没有什么办法固定住标题栏,而下面的不动呢?答案是有的。我们来试试adjustResize
android:windowSoftInputMode="adjustResize"
尴尬了,这个值直接不做任何布局反应,完全遮挡住输入框。
再来试试套ScrollView
大法:
经测试,外层套一个ScrollView
很完美应对"自定义标题栏不动,多编辑框界面能保持上移输入时可见"
的需求。而此时无论有没有设置adjustResize
或者adjustPan
不再有关系。但是简单解决方案只能应对特殊的情况,一般来讲这还不够自由,不够一般性治标不治本。
2.需求:“全屏下adjustResize失效,解决底部编辑框被软键盘遮挡”
问题表现:
简单的布局下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--自定义Linenearlayout-->
<com.example.schoolservice.view.ChatSendBottom
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom=