
所以这是我没有键盘显示的初始状态.
这是键盘出现时发生的情况.
这就是我想要实现的目标.
注意
我目前正在使用“adjust-resize”作为windowsoftinputMode.我知道使用“adjust-pan”会解决这个问题,但是“adjust-pan”有两个问题:
>工具栏也向上移动,为编辑文本和键盘腾出空间.
> editText部分由键盘覆盖.
这里需要布局专家的帮助!
提前致谢.
编辑:
这就是我的XML的样子:
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"> <linearLayout androID:ID="@+ID/vIEw_group_toolbar" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:background="@color/colorPrimaryDark" androID:elevation="4dip" > <!-- Toolbar stuff --> </androID.support.v7.Widget.Toolbar> </linearLayout> <linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_above="@+ID/bottom_bar" androID:layout_below="@+ID/vIEw_group_toolbar" androID:orIEntation="vertical"> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="0.6"> <include layout="@layout/layout_that_covers_60%_of_the_screen (This is not my actual layout name :/ using it for understandability)" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" /> </linearLayout> <linearLayout androID:ID="@+ID/vIEw_group_recycler_vIEw" androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="0.4" androID:gravity="center_vertical"> <include layout="@layout/layout_that_covers_40%_of_the_screen" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" /> </linearLayout> </linearLayout> <relativeLayout androID:ID="@+ID/bottom_bar" androID:layout_wIDth="match_parent" androID:layout_height="60dip" androID:layout_alignParentBottom="true" androID:gravity="bottom" androID:padding="8dip" > <!-- This is where my edit text resIDes --> </relativeLayout> </relativeLayout>解决方法 所以这就是我认为你应该做的,
使用
windowsoftinputMode =“adjustResize” – 活动的主窗口始终调整大小,以便为屏幕上的软键盘腾出空间. adjustResize还可以将Toolbar保持在最顶层.
尝试在nestedScrollVIEw中添加两个linearLayouts.我之所以这样说是因为您的nestedScrollVIEw内容可以向上滚动.
我认为你的布局看起来像这样.
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:app="http://schemas.androID.com/apk/res-auto"xmlns:tools="http://schemas.androID.com/tools"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"><linearLayout androID:ID="@+ID/vIEw_group_toolbar" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:background="@color/colorPrimaryDark" androID:elevation="4dip" > <!-- Toolbar stuff --> </androID.support.v7.Widget.Toolbar></linearLayout><nestedScrollVIEw androID:layout_above="@+ID/bottom_bar" androID:layout_below="@+ID/vIEw_group_toolbar"> <linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical"> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="0.6"> <include layout="@layout/layout_that_covers_60%_of_the_screen (This is not my actual layout name :/ using it for understandability)" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" /> </linearLayout> <linearLayout androID:ID="@+ID/vIEw_group_recycler_vIEw" androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="0.4" androID:gravity="center_vertical"> <include layout="@layout/layout_that_covers_40%_of_the_screen" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" /> </linearLayout> </linearLayout></nestedScrollVIEw><relativeLayout androID:ID="@+ID/bottom_bar" androID:layout_wIDth="match_parent" androID:layout_height="60dip" androID:layout_alignParentBottom="true" androID:gravity="bottom" androID:padding="8dip" > <!-- This is where my edit text resIDes --></relativeLayout>
如果这对您有用,请告诉我.
编辑1:
如果布局中有RecyclerVIEw,则可能需要设置此属性以实现平滑滚动 –
recyclerVIEw.setnestedScrollingEnabled(false);总结
以上是内存溢出为你收集整理的Android线性布局重量和软键盘问题全部内容,希望文章能够帮你解决Android线性布局重量和软键盘问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)