2015-10-26 144 views
0

我必须实现viewpager与headerview和可折叠工具栏。我已经实现了,但目前滚动只能在viewpager视图上,而不是在headerview上。 请让我知道解决此问题的方法。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

结帐https://androidbeasts.wordpress.com/2015/09/27/working-with-material-design-and-activity-transition/,它可能会帮助 – Aakash

+0

@Aakash:谢谢。但我担心的是,当我试图在ImageView上滚动时,滚动会起作用吗? –

回答

0

您TabLayout像headerview。尝试this sample。该示例实现了viewpager和tablayout & collapsingtoolbarlayout。

+0

感谢您的回复,但我认为您没有收到我的问题。 –

+0

ohh。打扰一下。但建议你确定使用https://github.com/chrisbanes/cheesesquare – MHossein

+0

该示例包含设计库,但我希望headerview with viewpager。 –