Hello all! I want to keep my toolbar always on the...
# compose
m
Hello all! I want to keep my toolbar always on the top and navigate screens under of it in fully compose project. I couldn’t find a way for this, do you have idea? Normally it can be done like this in XML way:
Copy code
<?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>"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.fragment.app.FragmentContainerView
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/toolbar"
        app:navGraph="@navigation/nav_graph" />

</androidx.constraintlayout.widget.ConstraintLayout>
e
Use Scaffold. It allows for you to define a topbar, content, and bottombar composable
m
I don’t want to each screens have their toolbar
e
right and your nav graph goes in the content section
you navigate within the content
m
got it
how I couldn’t think this 🤦‍♂️
Thank you @Eric Chee
e
Np, simple solutions always gets the best of us lol