我是Android编程的新手。我想问一下,Toolbar
能在RelativeLayout
中工作吗?到目前为止,我使用LinearLayout
创建了它们。希望听到大家的指导。谢谢。
问题是:如何防止内容重叠在Toolbar
上方。
我是Android编程的新手。我想问一下,Toolbar
能在RelativeLayout
中工作吗?到目前为止,我使用LinearLayout
创建了它们。希望听到大家的指导。谢谢。
问题是:如何防止内容重叠在Toolbar
上方。
是的,我们可以在相对布局中添加工具栏。
但是你需要提到“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>