I'm new in Android Programming. I would like to ask that does Toolbar
able to work in RelativeLayout
? So far I manage to create them using LinearLayout
. Would like to hear some guidance form you all. Thanks.
The question is: how do I prevent the content from overlaying on top of the Toolbar
content?
Yes, we can add toolbar within Relative layout .
But you need to mention layout:below attribute since it will overlap.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With