我必须使用headerview和Collapsible Toolbar实现viewpager。我已经实现了,但目前滚动只适用于viewpager视图而不是headerview。 请让我知道解决此问题的方法。
这是我的布局。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:gravity="center">
<LinearLayout
android:id="@+id/lnrHeader"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:visibility="gone">
<include
layout="@layout/toolbarHeaderLayout" />
</LinearLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:id="@+id/id_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/lnrCustomProfile"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--- Header Layout--->
<include
layout="@layout/customprofileshoplayout" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dividerline"
android:background="@color/colorGrayBorder"
android:layout_above="@+id/tabsProfile" />
<android.support.design.widget.TabLayout
android:id="@id/tabsProfile"
app:tabGravity="fill"
app:tabMode="fixed"
android:background="@color/white"
app:tabIndicatorColor="@color/black"
app:tabSelectedTextColor="@color/tabSelectColor"
app:tabTextColor="@color/tabColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lnrCustomProfile" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dividerline"
android:background="@color/colorGrayBorder"
android:layout_below="@id/tabsProfile" />
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<ViewPager
android:id="@+id/vwpagerProfileProducts"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:0)
你的TabLayout就像headerview一样。试试this sample。示例实现了viewpager和tablayout&amp; collapsingtoolbarlayout。