扫码关注官方订阅号
ringa_lee
给整个布局文件嵌套个ScrollView试试
这样:
<LinearLayout ... > <Toolar ... /> <ScrollView ... > <Edittext ... /> ... </ScrollView> </LinearLayout>
碰巧我在开发的过程中也遇到了这个问题我的解决方案如下1.在所需要的布局上添加入Scrollview
<ScrollView ... > <Edittext ... /> ... </ScrollView>
2.如果有设置windowSoftInputMode="adjustPan" 取消该设置
如果此时发现不生效 3.在你的根布局的layout 下设置android:fitsSystemWindows="true" 参考 http://stackoverflow.com/questions/7417123/android-how-to-adjust-layout-in-full-screen-mode-when-softkeyboard-is-visible
4.如果有部分机型发现状态栏布局变透明参考 http://stackoverflow.com/questions/21092888/windowsoftinputmode-adjustresize-not-working-with-translucent-action-navbar自定义了一个layout继承你的根layout。重写fitSystemWindows方法,并且在根layout中声明 fitSystemWindows="true"
自定义布局
package com.meizu.mzbbs.widget; import android.content.Context; import android.graphics.Rect; import android.os.Build; import android.util.AttributeSet; import android.view.WindowInsets; import android.widget.RelativeLayout; /** * Created by yangjingxuan on 16/6/15. */ public class SoftInputRelativeLayout extends RelativeLayout { private int[] mInsets = new int[4]; public SoftInputRelativeLayout(Context context) { super(context); } public SoftInputRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override public WindowInsets computeSystemWindowInsets(WindowInsets in, Rect outLocalInsets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // Intentionally do not modify the bottom inset. For some reason, // if the bottom inset is modified, window resizing stops working. // TODO: Figure out why. mInsets[0] = outLocalInsets.left; mInsets[1] = outLocalInsets.top; mInsets[2] = outLocalInsets.right; outLocalInsets.left = 0; outLocalInsets.top = 0; outLocalInsets.right = 0; } return super.computeSystemWindowInsets(in, outLocalInsets); } @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { mInsets[0] = insets.getSystemWindowInsetLeft(); mInsets[1] = insets.getSystemWindowInsetTop(); mInsets[2] = insets.getSystemWindowInsetRight(); return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom())); } else { return insets; } } }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
给整个布局文件嵌套个ScrollView试试
这样:
碰巧我在开发的过程中也遇到了这个问题
我的解决方案如下
1.在所需要的布局上添加入Scrollview
2.如果有设置windowSoftInputMode="adjustPan" 取消该设置
如果此时发现不生效
3.在你的根布局的layout 下设置
android:fitsSystemWindows="true"
参考 http://stackoverflow.com/questions/7417123/android-how-to-adjust-layout-in-full-screen-mode-when-softkeyboard-is-visible
4.如果有部分机型发现状态栏布局变透明
参考 http://stackoverflow.com/questions/21092888/windowsoftinputmode-adjustresize-not-working-with-translucent-action-navbar
自定义了一个layout继承你的根layout。
重写fitSystemWindows方法,并且在根layout中声明 fitSystemWindows="true"
自定义布局