/**
* 解决透明状态栏下,布局无法自动拉起的问题
* 手动设置View的高度
*/
private void setInput() {
final View rootView = ((ViewGroup) this.findViewById(android.R.id.content))
.getChildAt(0);
final View decorView = getWindow().getDecorView();
decorView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect rect= new Rect();
decorView.getWindowVisibleDisplayFrame(rect);
int screenHeight = decorView.getRootView().getHeight();
int heightDifferent = screenHeight - rect.bottom;
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams();
lp.setMargins(0, 0, 0, heightDifferent);
rootView.requestLayout();
}
});
}
【Android】4.4以上使用透明状态栏后布局被软键盘遮挡的解决办法
最新推荐文章于 2022-06-23 11:44:10 发布