-2
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"/>

    </android.support.design.widget.AppBarLayout>


    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/tab_bar" />

    <com.whl.handytabbar.HandyTabBar
        android:id="@+id/tab_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:background="@drawable/custom_shadow" />

</android.support.design.widget.CoordinatorLayout>
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
Nikhil Borad
  • 2,065
  • 16
  • 20

3 Answers3

2

Toolbar is inside an AppBarLayout which is probably inside your CoordinatorLayout then something like this should work.

AppBarLayout appBarLayout = (AppBarLayout)findViewById(R.id.appBar);
        appBarLayout.setExpanded(true, true);

Or to collapse toolbar then something like this should work

AppBarLayout appBarLayout = (AppBarLayout)findViewById(R.id.appBar);
        appBarLayout.setExpanded(false, true);
Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31
  • This is some documentation [https://developer.android.com/reference/android/support/design/widget/AppBarLayout.html#setExpanded(boolean)] for refrence. – Ratilal Chopda May 19 '17 at 05:57
0

Follow this link you will get your answer here :

How to hide ToolBar when i scrolling content up in android

Community
  • 1
  • 1
Akash Shah
  • 15
  • 4
-1

you need this app:layout_behavior="@string/appbar_scrolling_view_behavior" in your scroll view ase below:

 <android.support.v7.widget.RecyclerView
    android:id="@+id/rvToDoList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

we need to define an association between the AppBarLayout and the View that will be scrolled. Add an app:layout_behavior to a RecyclerView or any other View capable of nested scrolling such as NestedScrollView. The support library contains a special string resource @string/appbar_scrolling_view_behavior that maps to AppBarLayout.ScrollingViewBehavior, which is used to notify the AppBarLayout when scroll events occur on this particular view. The behavior must be established on the view that triggers the event.

You should take a look at This Guide

Kingfisher Phuoc
  • 8,052
  • 9
  • 46
  • 86