java - Android弹出软键盘时底部菜单与ScrollView冲突的问题
黄舟
黄舟 2017-04-17 13:30:13
[Java讨论组]

如图所示,应用底部有个菜单,上面是个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>

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(3)
天蓬老师
 android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"]

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

PHP中文网

比较简单的说法,就是设置scrollview的contentInset.bottom为键盘高度。这样应该可以的吧。。

阿神

adjustResize模式,你试试。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号