移动端,软键盘落下之后,安卓页面空白或者ios页面被透明遮罩

其实方法有好几种,比如说你们直接用flex布局,那么就完全没有这个烦恼。

但是如果真的遇见了,ios很简单,直接对body的scrollTop改写。

安卓可以试试如下方式:

一: 将元素的position设置成static或者relative,就是不要跟之前的方式一样

因为使用fixed或者absolute,会使得元素跟随body的底部弹起而移动。

 

二: 写个监听resize事件

document.getElementsByTagName("body")[0].style.height = document.body.scrollHeight+"px";//防止页面软键盘落下后还有白色的北京
$(window).resize(function() {
    $('body').height(Height);
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要给Android页面加上层,并设置某个控件不被,你可以按照以下步骤进行: 1. 创建一个层布局文件(例如`mask_layout.xml`),定义一个半透明的背景和一个覆盖整个屏幕的View: ```xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <View android:id="@+id/mask_view" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#80000000" /> <!-- 其他层内容 --> </RelativeLayout> ``` 2. 在需要添加层的Activity的布局文件中,使用`FrameLayout`作为根布局,并将层布局文件和Activity的内容布局文件添加进去: ```xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 层布局 --> <include layout="@layout/mask_layout" /> <!-- Activity的内容布局 --> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 其他控件 --> <!-- 目标控件,不被 --> <Button android:id="@+id/target_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Target Button" /> <!-- 其他控件 --> </LinearLayout> </FrameLayout> ``` 3. 在Activity的Java代码中,设置目标控件(例如按钮)不受影响,即为其设置点击事件,并在点击事件中移除层: ```java public class MainActivity extends AppCompatActivity { private View maskView; private Button targetButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); maskView = findViewById(R.id.mask_view); targetButton = findViewById(R.id.target_button); targetButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 移除层 maskView.setVisibility(View.GONE); } }); } } ``` 通过以上步骤,你可以在Android页面上添加一个层,并设置目标控件不受影响。当目标控件被点击时,移除层即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值