开发者社区> 问答> 正文

Android弹出软键盘时底部菜单与ScrollView冲突的问题

如图所示,应用底部有个菜单,上面是个ScrollView,弹出键盘是我希望菜单跟随着键盘移动到上面,但是此时会遮挡输入光标。比如,我点了test12,焦点处于test12上,但是正好被菜单给挡住了,有什么好的办法解决这个问题吗?

  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
       <LinearLayout
           android:orientation="vertical"
           android:layout_gravity="center_vertical"
           android:layout_width="match_parent"
           android:layout_height="wrap_content">
           <EditText
               android:hint="test1"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test2"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test3"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test4"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test5"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test6"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test7"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test8"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test9"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test10"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test11"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test12"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test13"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
           <EditText
               android:hint="test14"
               android:layout_width="match_parent"
               android:layout_height="50dp" />
       </LinearLayout>
    </ScrollView>
    <LinearLayout
        android:layout_alignParentBottom="true"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:gravity="center_horizontal"
            android:background="#FFAA00"
            android:text="我的菜单"
            android:textSize="40sp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</RelativeLayout>

screenshot
screenshot

展开
收起
蛮大人123 2016-02-27 18:36:08 3354 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪
    android:windowSoftInputMode=["stateUnspecified",
                                           "stateUnchanged", "stateHidden",
                                           "stateAlwaysHidden", "stateVisible",
                                           "stateAlwaysVisible", "adjustUnspecified",
                                           "adjustResize", "adjustPan"]

    键盘的弹出有这么几种模式,可以组合着使用 ,你试试adjustResize和adjustPan,以及组合使用stateVisible试试。

    2019-07-17 18:49:13
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载