问题: 

1、页面布局文件:

<com.zhy.autolayout.AutoLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/layout_order_detail"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:fitsSystemWindows="true"    android:orientation="vertical">

2、配置文件不设置android:windowSoftInputMode属性;

 

效果图:

Android输入法遮挡了输入框,使用android:fitsSystemWindows=

 

3、加入android:fitsSystemWindows="true"后,解决了输入法遮挡了输入框的问题,但是界面顶部出现了状态栏高度的白条。

 

解决方法:

1、自定义CustomLinearLayout(因为我页面最外层是LinearLayout)继承LinearLayout,重写fitSystemWindows和onApplyWindowInsets两个方法:

public class CustomLinearLayout extends AutoLinearLayout {    public CustomLinearLayout(Context context) {        super(context);    }    public CustomLinearLayout(Context context, AttributeSet attrs) {        super(context, attrs);    }    public CustomLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {        super(context, attrs, defStyleAttr);    }    public CustomLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {        super(context, attrs, defStyleAttr, defStyleRes);    }    @Override    protected boolean fitSystemWindows(Rect insets) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            insets.left = 0;            insets.top = 0;            insets.right = 0;        }        return super.fitSystemWindows(insets);    }    @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)    @Override    public WindowInsets onApplyWindowInsets(WindowInsets insets) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom()));        } else {            return insets;        }    }}

2、修改布局文件:

<com.example.widget.CustomLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/layout_order_detail"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:fitsSystemWindows="true"    android:orientation="vertical">

3、配置文件不设置android:windowSoftInputMode属性;

4、效果图:

Android输入法遮挡了输入框,使用android:fitsSystemWindows=

问题解决。

更多相关文章

  1. Android 输入法键盘和activity页面遮挡问题解决
  2. android 修改谷歌拼音输入法全屏时的高度
  3. Android修改输入法Enter的文本
  4. Android如何避免输入法弹出时遮挡住按钮或输入框
  5. Android:EditText屏蔽输入法弹窗
  6. Android:UI设置-横竖屏转换、输入法键盘相关设置
  7. android EditText设置弹出数字输入法键盘
  8. android输入法手势程序源码

随机推荐

  1. Andoid Studio 删除项目
  2. Android的广播初步了解
  3. Android(安卓)button 居中
  4. android自动化之MonkeyRunner测试环境配
  5. Android培训---创建Android工程
  6. Android(安卓)ApiDemos示例解析(53):Grap
  7. 【OpenCV】编译opencv+opencv_contrib sd
  8. android 标题栏的高度
  9. Xamarin.Forms Android的本地数据库SQLit
  10. 动态调试Android笔记