Android 相对布局:最后一个视图组不会越过标题?



我希望最后一个带有ID聊天的ViewGroup与先前的ViewGroup重叠并占据我手机的整个屏幕。在下面的XML代码中,我认为它将得到我想要的。但是代码没有。请帮助。

以下是XML代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.testapp.MainActivity">
<LinearLayout
    android:id="@+id/bar"
    android:layout_alignParentStart="true"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:background="#999999"
    android:elevation="10dp"
    android:layout_width="match_parent"
    android:layout_height="40dp">
    <ImageView
        android:id="@+id/bar_img"
        android:src="@drawable/ic_autorenew_black_24dp"
        android:gravity="clip_vertical"
        android:paddingStart="8dp"
        android:layout_width="36dp"
        android:layout_height="36dp" />
    <TextView
        android:id="@+id/bar_title"
        android:text="title"
        android:ellipsize="end"
        android:layout_weight="1"
        android:gravity="center"
        android:textColor="#ffffff"
        android:textStyle="bold"
        android:textSize="18sp"
        android:layout_width="0dp"
        android:layout_height="wrap_content" />
</LinearLayout>
<FrameLayout
    android:id="@+id/root_frag"
    android:layout_below="@id/bar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></FrameLayout>
<LinearLayout
    android:id="@+id/chats"
    android:background="#ea2312"
    android:orientation="vertical"
    android:layout_alignParentStart="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/chat_list"
        android:orientation="vertical"
        android:layout_width`enter code here`="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:text="hello world"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>
</RelativeLayout>

这是预览屏幕截图。

在此处输入图像描述

" chats" LinearLayout di 填充整个屏幕,但是" bar" LinearLayout出现在其顶部(即使它在 RelativeLayout中以前定义了)由于其android:elevation属性。

要使此停止,要么从" bar"视图中删除 elevation attr,要么添加一个(较大) elevation attr

最新更新