Aria Vaghef
Aria Vaghef

Reputation: 1

How to prevent toolbar from hiding when my dynamic list is short?

I used NestedScrollview and CoordinatorLayout to hide toolbar when user scrolls a list, and it works, but the problem is when the list is short and won't scroll. I don't want toolbar to get hidden when the list is short and not scrollable. Any suggestion?

For an example of code, you can read this tutorial:

How to hideshow Toolbar when list is scrolling(part3)

<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/coordinatorLayout"
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
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"/>

    <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="@android:color/white"
            app:tabSelectedTextColor="@android:color/white"
            app:tabIndicatorColor="@android:color/white"
            app:tabIndicatorHeight="6dp"/>

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

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

As you can see tab1 has a long list and it can be scrolled, but tab2 has a short list, and can not be scrolled. However, the toolbar will get hidden when user swipes up on tab2.

How can I stop it?

tab1 vs tab2

Upvotes: 0

Views: 241

Answers (0)

Related Questions