解决ListView被底部控件遮挡问题

关键点使用相对布局重点将底部指定到listView下面,并且注意设置权重,亲测有效 

解决办法
android:layout_weight="1"


解决前
<?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"
    >
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <ListView
            android:id="@+id/msg_list_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:divider="@null"
            android:listSelector="@android:color/transparent"
            android:transcriptMode="alwaysScroll"
            android:fadingEdge="none"
            android:fastScrollEnabled="true"
            android:scrollbarStyle="insideInset"
            android:scrollingCache="false"
            android:stackFromBottom="true"
            >
        </ListView>
    </FrameLayout>
    <LinearLayout
        android:id="@+id/chat_bottom_view"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="@color/bottom_menu_bg_color"
        android:paddingRight="5dp"
        android:paddingLeft="5dp"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:gravity="center_vertical"
        >
        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:src="@mipmap/ic_record_voice"
            />
        <EditText
            android:id="@+id/msg_content_et"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textSize="@dimen/button_text_size"
            android:textCursorDrawable="@null"
            android:background="@drawable/chat_edit_text_bg"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="5dp"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:clickable="true"
            />
        <TextView
            android:id="@+id/msg_send_bt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="4"
            android:background="@drawable/circel_button_selector"
            android:textColor="@color/primaryTextColor"
            android:text="@string/send_msg"
            android:gravity="center"
            android:layout_marginRight="5dp"
            />
    </LinearLayout>
</RelativeLayout>


解决后
<?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"
    >
    <ListView
        android:id="@+id/msg_list_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:divider="@null"
        android:listSelector="@android:color/transparent"
        android:transcriptMode="alwaysScroll"
        android:fadingEdge="none"
        android:fastScrollEnabled="true"
        android:scrollbarStyle="insideInset"
        android:scrollingCache="false"
        android:stackFromBottom="true"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/chat_bottom_view"
        >
    </ListView>

    <LinearLayout
        android:id="@+id/chat_bottom_view"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@color/bottom_menu_bg_color"
        android:layout_alignParentBottom="true"
        android:paddingRight="5dp"
        android:paddingLeft="5dp"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:gravity="center_vertical"
        >
        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:src="@mipmap/ic_record_voice"
            />
        <EditText
            android:id="@+id/msg_content_et"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textSize="@dimen/button_text_size"
            android:textCursorDrawable="@null"
            android:background="@drawable/chat_edit_text_bg"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="5dp"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:clickable="true"
            />
        <TextView
            android:id="@+id/msg_send_bt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="4"
            android:background="@drawable/circel_button_selector"
            android:textColor="@color/primaryTextColor"
            android:text="@string/send_msg"
            android:gravity="center"
            android:layout_marginRight="5dp"
            />
    </LinearLayout>
</RelativeLayout>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值