android键盘弹出之后界面整体上移,顶出去了

在开发Android类似微信QQ聊天界面时,遇到点击输入框后内容被键盘顶出的问题。通过在AndroidManifest.xml中为相应activity设置`android:windowSoftInputMode="stateVisible|adjustResize"`进行调整,但若listview设置了`android:scrollbars="none"`,可能导致此设置无效。移除`android:scrollbars="none"`属性,可以解决界面被挤压的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 关于android编写类似于微信QQ聊天界面,点击底部输入框之后内容被顶出的问题处理

 

AndroidManifest.xml文件中界面对应的activity里加入

android:windowSoftInputMode="stateVisible|adjustResize"  配置之后压缩listview

 

注意:此处可能设置android:windowSoftInputMode="stateVisible|adjustResize" 无效,我的原因是因为去掉了listview滚动条(android:scrollbars="none")导致,去掉该属性完美解决

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/ll_top"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#F86630" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="top"
            android:textColor="#FFFFFF"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll_bottom"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#77DA83"
        android:orientation="horizontal" >

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="4" />

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="ok" />
    </LinearLayout>

    <ListView
        android:id="@+id/lv_list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/ll_bottom"
        android:layout_below="@id/ll_top" >
    </ListView>

</RelativeLayout>

 



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值