android 键盘遮挡解决办法

本文介绍了一种简单的方法来解决Android应用中键盘遮挡输入框的问题,通过在AndroidManifest.xml文件中设置windowSoftInputMode属性为adjustResize,并在布局文件中添加android:fitsSystemWindows=true来适配沉浸式标题栏。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

android的键盘遮挡比较常见,常见的方式就是使用代码动态改变,
其实没必要那么麻烦,只需几个步骤就可以了
这样就可以了
windowSoftInputMode=”adjustResize”

但是如果设置了沉浸式标题,还需要在布局文件的根节点上加上即可
android:fitsSystemWindows=”true”

很多人需要代码算的原因是因为根本没有了解,所以才出现各种的代码算法

题外话,推荐一款很好用的沉浸式标题栏控件
compile ‘com.readystatesoftware.systembartint:systembartint:1.0.4’

//启用沉浸式标题栏,并改变颜色
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setTintColor(getResources().getColor(R.color.system_bg));
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值