Android 工具栏是否可以在RelativeLayout中工作?

Android 工具栏是否可以在RelativeLayout中工作?,android,android-toolbar,Android,Android Toolbar,我是Android编程新手。我想问一下,工具栏是否能够在RelativeLayout中工作?到目前为止,我使用LinearLayout创建了它们。我想听听大家的意见。谢谢 问题是:如何防止内容覆盖在工具栏内容的顶部?是的,我们可以在相对布局中添加工具栏 但您需要提到layout:below属性,因为它将重叠 activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android

我是Android编程新手。我想问一下,
工具栏
是否能够在
RelativeLayout
中工作?到目前为止,我使用
LinearLayout
创建了它们。我想听听大家的意见。谢谢


问题是:如何防止内容覆盖在
工具栏
内容的顶部?

是的,我们可以在相对布局中添加工具栏

但您需要提到layout:below属性,因为它将重叠

activity_main.xml

<?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:orientation="vertical" >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:background="#ffbb00">


    </android.support.v7.widget.Toolbar>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="49dp"
        android:src="@drawable/ic_launcher" />

</RelativeLayout>


我看不出它怎么会不起作用。它在旧版本的Android上不起作用,除非在工具栏下方的视图中指定了布局:down,它会重叠。最好只将工具栏添加到末尾(因此它会在顶部),例如,如果你制作一个视频播放器,你希望透明的工具栏而不是视频