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

checkout 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

Образец содержит библиотеку Design, но я хочу headerview с viewpager. –

Смежные вопросы