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

关于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>  
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容