I have made Toolbar using coordinate toolbar in my app so that i can hide toolbar
while scrolling . I also have ViewPager
inside it . So when user scroll only Toolbar hides and tabs stick to the top . But in other activity i just want to display toolbar what is the better way to that ?
I am sharing my coordinator layout below
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/AppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/orange"
app:layout_scrollFlags="scroll|enterAlways"
app:titleTextColor="@color/white">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/MyTabLayout"
style="@style/TabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
app:tabTextAppearance="@style/AppTabTextAppearance">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/MyViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/MyTabLayout"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
></android.support.v4.view.ViewPager>
</android.support.design.widget.CoordinatorLayout>