android 输入法弹出布局自动上移,android输入法弹出时,整个页面上移(使输入法位于页面底部),怎么实现?...

我的思路:使用ScrollView将中间的主体内容包住,再把ScrollView的滚动条去掉。

效果和布局代码如下:

注:我目前测试的,只有Android4.4的机器上下面的布局还是不能上移,不知道原因希望共同探讨。

更新答案:4.4的bug解决,说起来也是自己作死为了适配4.4 的状态栏颜色,特意在stylev19中加了一行:true

就是这一行代码导致4.4上无效,目前原因不明。

提醒下,最好还是在清单文件中 加上

android:windowSoftInputMode="adjustResize"

bVqavs

我为了下面的『下一步』按钮能够永远显示在底部,用一个linearlayout 的android:layout_weight=1做了一个嵌套。

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:gravity="bottom"

android:orientation="vertical"

tools:context="com.luckingus.sns.ui.account.InviteActivity">

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实现输入后,布局整体上的效果可以通过给根布局设置android:fitsSystemWindows="true"属性来实现。 同,为了使顶部部分固定,可以将顶部部分放在一个固定高度的布局中,将中间部分放在一个可滚动的布局中。当输入,中间部分的布局会被上,而顶部部分则不会受到影响。 以下是一个示例布局文件: ``` <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <!-- 顶部部分,设置固定高度 --> <RelativeLayout android:id="@+id/top_layout" android:layout_width="match_parent" android:layout_height="60dp" android:background="@color/colorPrimary"/> <!-- 中间部分,放在可滚动的布局中 --> <ScrollView android:layout_below="@id/top_layout" android:layout_above="@+id/bottom_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- 中间部分的内容 --> </LinearLayout> </ScrollView> <!-- 底部部分,放置输入框等控件 --> <RelativeLayout android:id="@+id/bottom_layout" android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- 底部部分的控件 --> </RelativeLayout> </RelativeLayout> ``` 注意,这只是一个示例布局,具体实现还需要根据实际需求进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值