android弹出输入法时将按钮向上顶,Android输入法弹出时把布局顶上去和登录按钮顶上去的解决方法...

背景:在写登录界面时,老板就觉得在输入密码的时候谈出来的输入法软键盘把登录按钮遮挡住了(入下图所示,不爽),连输入框都被挡了一半,于是不满意了,要叫我改,于是我看QQ的登录效果,我就去研究了一下,弹出输入法整个布局上来了,终于让老板满意了。

47a21b20cb7e30b9d8b7cd8f5cbc038e.png

a077e2ff8a3a8ba57e694d3253b1596d.png

(如上图这样,老板不满意的,呵呵)

1,咱们就解决问题吧。

我看了很多博客和问答,很多人都说直接在在AndroidManifest.xml中给这个Activity设置 这样就好使了,这个是否在逗,整个布局向上移动并不明显,反正我的是不好使,不知道那些博主是怎么弄好使的。不过,看评论,也有很多人说不好使。那就做一个大家都好使的代码出来。先看效果。

b0c1a160274d8a9900a8a439fc5a87f0.png

c7ab47a2a8fb6cffc6636ce0b7191e26.png

哈哈,大家有没有看到,连登录按钮都一起跑上去了,应该是顶上去的。老板再也不用担心登录按钮被覆盖掉了。

那咱们就上代码啦:代码不多,全在布局上,就可以解决。

android:layout_width="match_parent" android:layout_height="match_parent"

android:fillViewport="true"

android:fadeScrollbars="true">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:gravity="top|center_horizontal"

android:orientation="vertical"

android:background="@color/red2"

android:visibility="visible">

android:layout_width="200dp"

android:layout_height="160dp"

/>

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:alwaysDrawnWithCache="true"

android:gravity="center|center_horizontal"

android:orientation="vertical"

android:visibility="visible"

android:background="@color/abc_search_url_text_normal">

android:background="@color/white"

android:layout_width="200dp"

android:layout_height="60dp"

/>

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:background="@color/cornsilk"

android:gravity="top|center_horizontal"

android:orientation="vertical"

android:visibility="visible">

android:layout_marginTop="20dp"

android:gravity="center"

android:text="登录"

android:layout_width="200dp"

android:layout_height="50dp" />

  对上面就是所有视线代码了,外面一个scrollview,包含一个LinearLayout,在中间包含了三个LinearLayout
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值