I am using androidx.coordinatorlayout.widget.CoordinatorLayout in my HomeActivity.xml file where I have used the <include>
layout="@layout/layout_top_tabs"> tag which is placing the layout at the (0,0) position of the screen (top left corner) which is not what I want. I have used <merge>
tags inside layout_top_tabs.xml file. When I remove the <merge>
tag, the <include>
tag works just fine. I don't know where I am going wrong. Please help!
activity_home.xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Top Toolbar-->
<RelativeLayout
android:id="@+id/relLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/layout_top_tabs" />
</RelativeLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
layout_top_tabs.xml file:
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
</RelativeLayout>
</merge>
I am not getting any error message, but the layouts are not appearing as I have defined them in the xml files.