0

I am trying to learn Material Design, I am trying to make a layout like current layout of Whatsapp home screen

enter image description here

It all works fine i had set up my tabs and also able to make swipe layout in tabs, now when i tried to make AppBarLayout exit the screen along with content when scroll, so that my content gets some more height while scrolling and my toolbar hide while scrolling. For that,

I had included NestedScrollView as parent of my content_main layout, And i included that content_main inside my activity_main but due to use of nested scroll view the swipe behavior of tabs are gone.

Currently its working like this but tabs are not swippable now, tabs are working properly when i clicked them.

What can be the issue?

content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">


    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <Button
                android:layout_width="match_parent"
                android:layout_height="1000dp"/>

        </LinearLayout>
    </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</layout>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<layout 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.support.design.widget.CoordinatorLayout
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context=".activity.MainActivity">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">

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

            <android.support.design.widget.TabLayout
                style="@style/MyCustomTabLayout"
                android:id="@+id/tabs_main"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                />

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

        <android.support.v4.view.ViewPager
            android:id="@+id/vp_main"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <include layout="@layout/content_main"
            android:id="@+id/content_main"/>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_activity_main"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="@dimen/fab_margin"
            android:src="@android:drawable/stat_notify_sync_noanim" />

    </android.support.design.widget.CoordinatorLayout>
</layout>
TapanHP
  • 5,097
  • 5
  • 33
  • 64
  • You'll need to include your code. A similar setup certainly works for the [cheesesquare sample app](https://github.com/chrisbanes/cheesesquare) – ianhanniballake Aug 13 '16 at 04:55
  • yes i have already seen chhesefactory example but problem is i can not get reason why its happening with NestedScrollVIew i am editing my question please check it out @ianhanniballake – TapanHP Aug 13 '16 at 04:57

0 Answers0