Android 设置状态栏后adjustResize属性无效
2017-07-01 17:04
405 查看
这两天被这个问题搞得很焦灼,今天终于解决了,在这里把自己解决的办法分享一下;
这是之前碰到的问题
如截图所示,输入框被遮住了
之前试过AndroidBug5497Workaround这个类,但发现在有些手机上无法做到适配,于是又到处找,最后终于找到了一种方法。
首先在对应的Activity里面设置
//根据输入法调节view的移动
然后重写根布局
只重写了fitSystemWindows方法。
然后在根布局里面设置
这个问题到这里就解决了。
这是之前碰到的问题
如截图所示,输入框被遮住了
之前试过AndroidBug5497Workaround这个类,但发现在有些手机上无法做到适配,于是又到处找,最后终于找到了一种方法。
首先在对应的Activity里面设置
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
//根据输入法调节view的移动
然后重写根布局
public class FullScreenLinearLayout extends LinearLayout { private int[] mInsets = new int[4]; public FullScreenLinearLayout(Context context) { super(context); } public FullScreenLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); } public final int[] getInsets() { return mInsets; } @Override protected final boolean fitSystemWindows(Rect insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { mInsets[0] = insets.left; mInsets[1] = insets.top; mInsets[2] = insets.right; return super.fitSystemWindows(insets); } else { return super.fitSystemWindows(insets); } } }
只重写了fitSystemWindows方法。
然后在根布局里面设置
android:fitsSystemWindows="true"
这个问题到这里就解决了。
相关文章推荐
- Android 设置状态栏后adjustResize属性无效
- android 软键盘挡住输入内容,adjustResize设置了也无效
- 解决android 软键盘在全屏下设置adjustResize无效的问题
- 解决android 软键盘在全屏下设置adjustResize无效的问题
- android 软键盘在全屏下设置adjustResize无效的问题
- android 解决沉浸式状态栏下adjustResize失效
- Android使用TextView,设置onClick属性无效解决办法
- android 当设置Activity状态栏为透明时,键盘弹出ScrollView滚动无效解决方案
- ScrollView中包含EditText,设置android:windowSoftInputMode="adjustPan"后无效
- 【Android】android:padding属性设置对ImageButton无效问题
- Android使用TextView,设置onClick属性无效的解决方法
- 关于设置android:imeOptions属性无效的解决办法
- android EditText中imeOptions属性设置无效解决方案
- android adjustresize not working when using windowTranslucentStatus,解决全屏效果与输入框属性冲突的问题
- Android 设置adjustResize失效
- Android使用TextView,设置onClick属性无效解决的方法
- Android使用TextView,设置onClick属性无效解决办法
- Android控件EditText的属性InputType的一些经验及动态设置TYPE_NUMBER_FLAG_DECIMAL无效的原因
- Android关于listview设置属性 android:listselector = "@null" 无效的问题
- android中actionbar的showAsAction属性设置为always无效解决方案