I have this in my activity_main file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity"
android:orientation="vertical">
<include layout="@layout/toolbar_layout"></include>
<FrameLayout
android:padding="4dp"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="120dp"
android:text="Fragment"
android:background="@drawable/border_menu_bottom"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingConstraints"
android:layout_alignParentBottom="true"
>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:backgroundTint="#535087"
android:contentDescription="Add Poll"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_add_poll"
android:layout_marginBottom="100dp"
tools:ignore="MissingConstraints" >
</com.google.android.material.floatingactionbutton.FloatingActionButton>
</RelativeLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="75dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_navigation"/>
<RelativeLayout
android:visibility="gone"
android:id="@+id/overlay"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
This in my toolbar_layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="130dp"
tools:context=".MainActivity"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:background="@drawable/main_image_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="20dp"
android:gravity="center"
>
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/ic_logo"
></ImageView>
</LinearLayout>
<LinearLayout
android:layout_marginTop="5dp"
android:paddingRight="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="9"
>
<LinearLayout
android:layout_weight="3"
android:id="@+id/iconProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profileImage"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginBottom="40dp"
app:civ_border_color="#ffffff"
app:civ_border_width="2dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/login_logo_font"
android:textAlignment="center"
android:text="PollIt"
android:textSize="25dp"
android:textColor="#6D4C41">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_weight="3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
>
<ImageView
android:id="@+id/iconRefresh"
android:layout_width="35dp"
android:layout_height="35dp"
android:gravity="right"
android:layout_marginBottom="40dp"
android:src="@drawable/ic_refresh"></ImageView>
<ImageView
android:layout_marginTop="-2dp"
android:id="@+id/iconSearch"
android:layout_marginLeft="10dp"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_marginBottom="40dp"
android:src="@drawable/ic_search"></ImageView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
And this in my follow_fragment layout where there is a RecyclerView:
<?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:background="#D7CCC8"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginBottom="60dp">
<androidx.recyclerview.widget.RecyclerView
android:layout_weight="1"
android:id="@+id/followInterestsList"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</RelativeLayout>
I’ve been trying using the CollapsableToolbarLayout but find the resources confusing as my layouts are different to the resources I have looked at.