软件盘将dialog顶上去_Android实现输入法弹出时把布局顶上去和登录按钮顶上去的解决方法...

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

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

1,咱们就解决问题吧。

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

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

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

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,当然了包含三个什么容器控件都行,但是一定要用权重(layout_weight)来约束,这是重点,我只说了一遍,还有就是LinearLayout内部的布局尽量用wrap_content,即时要固定高度也要适当,调节调节就好了。

使用的时候很简单,就只有上面一段布局,然而根本用不着神马AndroidManifest.xml中给这个Activity设置

对于这段代码,是可以将底部如果有输入框(最好用FrameLayout包裹),可以向上移动的&#x

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值