Vor kurzem habe ich Android Design Support Library verwendet und ich habe den folgenden Code für meine Symbolleiste kollabieren.CoordinatorLayout funktioniert nicht gut mit NestedScrollView und Viewpager
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/media_detail_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
>
<include
layout="@layout/layout_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/media_detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<android.support.design.widget.TabLayout
android:id="@+id/media_detail_tabs"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/blue_2"
app:tabMode="scrollable"
/>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Ich habe zwei Fragmente für den View Pager. Einer ist NestedScrollView und der andere ist Recycler View. Mein Problem ist die NestedScrollView, hier ist der Code unten.
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Mein Problem ist, dass wenn Sie die Ansicht nach oben bewegen, sobald Sie mit dem Finger ein bisschen auf der Seite bewegt, ist es den horizontalen Bildlauf für die Ansicht Pager auslöst. Könnten Sie mir bitte helfen, das zu vermeiden? Beim Scrollen nach oben und unten sollte der Pager nicht ausgelöst werden. Es funktioniert gut in meinem Recycler-View-Fragment. Vielen Dank.
Haben Sie eine Lösung für dieses Problem gefunden? – dgngulcan