我必須實現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>
結帳https://androidbeasts.wordpress.com/2015/09/27/working-with-material-design-and-activity-transition/,它可能會幫助 – Aakash
@Aakash:謝謝。但我擔心的是,當我試圖在ImageView上滾動時,滾動會起作用嗎? –