实现类似QQ、微信聊天界面,标题栏固定,键盘不遮挡底部输入框

1.AndroidManifest.xml里面对应的activity设置
android:windowSoftInputMode="adjustResize"

2.activity的xml
a.根节点加入
android:fitsSystemWindows="true"
b.为了更好的效果listview加入
android:transcriptMode="normal"

<?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"
    android:background="@color/white"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <include
        android:id="@+id/v_top"
        layout="@layout/title_layout_for_edittext" />

    <LinearLayout
        android:id="@+id/ll_bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/space_05"
            android:layout_alignParentTop="true"
            android:background="@color/line_Color" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="@dimen/space_6"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_marginRight="@dimen/activity_horizontal_margin"
            android:layout_marginTop="@dimen/space_6">

            <Button
                android:id="@+id/btn_send"
                android:layout_width="@dimen/space_75"
                android:layout_height="@dimen/space_38"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="@dimen/space_6"
                android:background="@drawable/round_corner_rectangle_small"
                android:gravity="center"
                android:text="发送"
                android:textColor="@color/white"
                android:textSize="@dimen/text_size_20" />

            <EditText
                android:id="@+id/et_edit_message"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/btn_send"
                android:background="@drawable/chat_edit_view_bg"
                android:maxHeight="@dimen/space_90"
                android:minHeight="@dimen/space_40"
                android:padding="@dimen/space_6"
                android:text=""
                android:textColor="@color/text_black_3"
                android:textSize="@dimen/text_size_16" />


        </RelativeLayout>

    </LinearLayout>

    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/ll_bottom"
        android:layout_below="@+id/v_top"
        android:divider="@null"
        android:dividerHeight="0dip"
        android:transcriptMode="normal" />


</RelativeLayout>



  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值