2016-05-20 12 views
0

Ich habe ein Layout, das Koordinator-Layout und ein Parallax Scroll-Bild verwendet. Alles funktioniert so, wie ich es möchte, wenn ich ziemlich langsam scrolle, aber wenn ich schnell scrolle oder den Bildschirm scrolle, um zu scrollen, erscheint das Bild über dem oberen Rand der Titelleiste. Ich kann dann zurück scrollen und es wird unter dem Bild und wieder oben auftauchen.Layer-Neuordnung beim schnellen Scrollen

ich eine Bildschirm-Aufnahme gemacht habe, was ich meine, das sollten Sie hier, um der Lage sein:

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/detail_coordinator_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="app.com.example.android.bulletpoints.ui.DetailActivityFragment"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:background="@color/white" 
     android:layout_height="@dimen/detail_photo_height"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|enterAlways"> 

      <ImageView 
       android:id="@+id/article_photo" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="?actionBarSize" 
       android:scaleType="centerCrop" 
       app:layout_collapseMode="parallax" /> 

     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:id="@+id/title_bar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@color/colorPrimary" 
       android:elevation="@dimen/bulletpoint_elevation" 
       android:orientation="vertical"> 

       <TextView 
        android:id="@+id/detail_title" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingEnd="@dimen/detail_bar_text_margin" 
        android:paddingLeft="@dimen/detail_bar_text_margin" 
        android:paddingRight="@dimen/detail_bar_text_margin" 
        android:paddingStart="@dimen/detail_bar_text_margin" 
        android:paddingTop="@dimen/detail_bar_title_top" 
        android:textColor="@color/white" 
        android:textSize="@dimen/detail_title_text_size" /> 

       <TextView 
        android:id="@+id/detail_subtitle" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingBottom="@dimen/detail_bar_subtitle_bottom" 
        android:paddingEnd="@dimen/detail_bar_text_margin" 
        android:paddingLeft="@dimen/detail_bar_text_margin" 
        android:paddingRight="@dimen/detail_bar_text_margin" 
        android:paddingStart="@dimen/detail_bar_text_margin" 
        android:textColor="@color/white" 
        android:textSize="@dimen/detail_subtitle_text_size" /> 
      </LinearLayout> 

      <FrameLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@color/white"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="@dimen/bulletpoint_block_bottom" 
        android:layout_marginEnd="@dimen/bulletpoint_margin" 
        android:layout_marginLeft="@dimen/bulletpoint_margin" 
        android:layout_marginRight="@dimen/bulletpoint_margin" 
        android:layout_marginStart="@dimen/bulletpoint_margin" 
        android:background="@color/white" 
        android:elevation="@dimen/bulletpoint_elevation" 
        android:orientation="vertical"> 

        <include 
         android:id="@+id/bulletpoint_1" 
         layout="@layout/bulletpoint_item" /> 

        <include layout="@layout/divider" /> 

        <include 
         android:id="@+id/bulletpoint_2" 
         layout="@layout/bulletpoint_item" /> 

        <include layout="@layout/divider" /> 

        <include 
         android:id="@+id/bulletpoint_3" 
         layout="@layout/bulletpoint_item" /> 

        <include layout="@layout/divider" /> 

        <include 
         android:id="@+id/bulletpoint_4" 
         layout="@layout/bulletpoint_item" /> 

        <include layout="@layout/divider" /> 

        <include 
         android:id="@+id/bulletpoint_5" 
         layout="@layout/bulletpoint_item" /> 

       </LinearLayout> 
      </FrameLayout> 
     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 

    <include layout="@layout/ad_fab" /> 

</android.support.design.widget.CoordinatorLayout> 

Ist jemand in der Lage zu sehen, wo: link

Hier wird die xml für das Layout ist Ich bin in meinem Layout falsch gelaufen? Jede Hilfe würde sehr geschätzt werden.

Edit: Ich hatte die oberste Ebene der XML-Datei verpasst weg, damit ich es in wieder hinzugefügt haben

Antwort

0

Es dauerte eine Menge Dinge, über das Verschieben, aber ich habe es gelöst, so dachte ich, ich. würde die Lösung posten, falls jemand anderes ein ähnliches Problem hatte.

Es lag an mir, über die Gruppierung falsch nachzudenken. Ich bin mir nicht sicher, warum es die Leiste unter dem Bild scrollen würde, aber ich denke, es hat etwas mit der NestedScrollView zu tun (, wenn jemand Einblick hat, warum dies ist bitte Kommentar).

Um das zu beheben, habe ich die Leiste in das CollapsingToolbarLayout gebracht und in ein FrameLayout unterhalb der Imageview eingefügt.

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/detail_coordinator_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="app.com.example.android.bulletpoints.ui.DetailActivityFragment"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/detail_photo_height"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|enterAlways"> 

      <ImageView 
       android:id="@+id/article_photo" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_marginTop="?actionBarSize" 
       android:scaleType="centerCrop" 
       app:layout_collapseMode="parallax"/> 

      <FrameLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" > 

       <LinearLayout 
        android:id="@+id/title_bar" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="@color/colorPrimary" 
        android:elevation="@dimen/bulletpoint_elevation" 
        android:layout_gravity="bottom" 
        android:orientation="vertical"> 

        <TextView 
         android:id="@+id/detail_title" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:paddingEnd="@dimen/detail_bar_text_margin" 
         android:paddingLeft="@dimen/detail_bar_text_margin" 
         android:paddingRight="@dimen/detail_bar_text_margin" 
         android:paddingStart="@dimen/detail_bar_text_margin" 
         android:paddingTop="@dimen/detail_bar_title_top" 
         android:textColor="@color/white" 
         android:textSize="@dimen/detail_title_text_size" /> 

        <TextView 
         android:id="@+id/detail_subtitle" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:paddingBottom="@dimen/detail_bar_subtitle_bottom" 
         android:paddingEnd="@dimen/detail_bar_text_margin" 
         android:paddingLeft="@dimen/detail_bar_text_margin" 
         android:paddingRight="@dimen/detail_bar_text_margin" 
         android:paddingStart="@dimen/detail_bar_text_margin" 
         android:textColor="@color/white" 
         android:textSize="@dimen/detail_subtitle_text_size" /> 
       </LinearLayout> 
      </FrameLayout> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <FrameLayout 
      android:id="@+id/bulletpoint_block" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/white"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="@dimen/bulletpoint_block_bottom" 
       android:layout_marginEnd="@dimen/bulletpoint_margin" 
       android:layout_marginLeft="@dimen/bulletpoint_margin" 
       android:layout_marginRight="@dimen/bulletpoint_margin" 
       android:layout_marginStart="@dimen/bulletpoint_margin" 
       android:background="@color/white" 
       android:elevation="@dimen/bulletpoint_elevation" 
       android:orientation="vertical"> 

       <include 
        android:id="@+id/bulletpoint_1" 
        layout="@layout/bulletpoint_item" /> 

       <include layout="@layout/divider" /> 

       <include 
        android:id="@+id/bulletpoint_2" 
        layout="@layout/bulletpoint_item" /> 

       <include layout="@layout/divider" /> 

       <include 
        android:id="@+id/bulletpoint_3" 
        layout="@layout/bulletpoint_item" /> 

       <include layout="@layout/divider" /> 

       <include 
        android:id="@+id/bulletpoint_4" 
        layout="@layout/bulletpoint_item" /> 

       <include layout="@layout/divider" /> 

       <include 
        android:id="@+id/bulletpoint_5" 
        layout="@layout/bulletpoint_item" /> 

      </LinearLayout> 
     </FrameLayout> 
    </android.support.v4.widget.NestedScrollView> 

    <include layout="@layout/ad_fab" /> 

</android.support.design.widget.CoordinatorLayout>