问题描述:

I have 2 layouts below:

layout 1:

<android.support.design.widget.AppBarLayout

android:layout_width="match_parent"

android:layout_height="wrap_content">

<android.support.design.widget.TabLayout

android:id="@+id/tabLayout"

style="@style/CustomTabLayoutFavoriteFragment"

android:layout_width="match_parent"

android:layout_height="?android:attr/actionBarSize"

android:background="@color/colorPrimary"

android:elevation="4dp"

android:theme="@style/ThemeOverlay.AppCompat.Dark"

app:layout_scrollFlags="scroll|enterAlways"

app:tabGravity="center"

app:tabMode="fixed"

tools:targetApi="lollipop" />

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

<android.support.v4.view.ViewPager

android:id="@+id/viewpager"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior" />

, and in my viewpager, my fragment's layout below

layout 2:

<android.support.v4.widget.SwipeRefreshLayout

android:id="@+id/layoutRefresh"

android:layout_width="match_parent"

android:layout_height="match_parent">

<FrameLayout

android:layout_width="match_parent"

android:layout_height="match_parent"

android:measureAllChildren="true">

<ScrollView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fillViewport="true">

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="@dimen/high_margin"

android:visibility="invisible">

<!--i have some components in here-->

</RelativeLayout>

</ScrollView>

<android.support.v7.widget.RecyclerView

android:id="@+id/recyclerView"

android:layout_width="match_parent"

android:layout_height="match_parent" />

</FrameLayout>

</android.support.v4.widget.SwipeRefreshLayout>

<android.support.design.widget.FloatingActionButton

android:id="@+id/fabAddBoard"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="end|bottom"

android:layout_margin="16dp"

android:background="?attr/selectableItemBackground"

android:theme="@style/ThemeOverlay.AppCompat.Dark"

app:backgroundTint="@color/colorPrimary"

app:srcCompat="@drawable/ic_add" />

(my layout 2 is wrapped in a coordinator layout but when i paste in here, it's not visible, i have no idea)

My question is : I want the tablayout in layout 1 to collapse when my recycler view in layout 2 scroll down. If I setup like 2 layouts above, whenever i swipe down the fragment, the tablayout collapse then(when my recycler view has no item or has some items). So, how can i achieve my goal?

P/s: please apologize for my bad english ^^

相关阅读:
Top