9

funktioniert habe ich eine Aktivität mit dem nächsten LayoutCoordinatorLayout nicht mit NestedScrollView innen Fragment in ViewPager

Aktivität Layout

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/issue_browse_app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/app_default_color" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/issue_browse_toolbar" 
     app:layout_scrollFlags="scroll|enterAlways" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" /> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/issue_browse_tab_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

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

<android.support.v4.view.ViewPager 
    android:id="@+id/issue_browse_view_pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

ViewPager nach Instanziierung hat 2 Fragmente

Erstes sichtbares Fragments Layout

<?xml version="1.0" encoding="utf-8"?> 
<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/issue_browse_view_switcher" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white"> 

    <FrameLayout 
     android:id="@+id/issue_browse_status_buttons_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


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

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

       <LinearLayout 
        android:id="@+id/issue_browse_fragment_view_container" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="start" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom" 
        android:layout_marginTop="1000dp" 
        android:text="end" /> 

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

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

     <TextView 
      android:id="@+id/issue_browse_load_error_text" 
      style="@style/list_view_empty_view_style" 
      android:drawableTop="@drawable/error" /> 

     <TextView 
      android:id="@+id/issue_browse_refresh_after_error" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginTop="@dimen/content_offset_small" 
      android:textColor="#c0bebe" /> 
    </LinearLayout> 
</ViewSwitcher> 

Wie man sehen kann, gibt es NestedScrollView mit App: layout_behavior = "@ Zeichenfolge/appbar_scrolling_view_behavior"

Und unabhängig von der Tatsache, hat NestedScrollView Dieses Tag oder nicht, der Koordinator versteckt die Toolbar nicht.

Wo ist ein Fehler in diesem Code?

+2

Haben Sie eine Lösung erhalten? –

Antwort

0

Sie sind nicht "CollapsingToolbarLayout"

Doc sagt mit:

CollapsingToolbarLayout ist ein Wrapper für Toolbar, die eine Kollabieren App-Leiste implementiert. Es ist so konzipiert, dass es als direktes Kind eines AppBarLayout verwendet werden kann.

Für Ihr Verständnis siehe unten Beispiel

<android.support.design.widget.CoordinatorLayout 
      android:id="@+id/main_content" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true"> 

      <android.support.design.widget.AppBarLayout 
       android:id="@+id/app_bar_layout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:fitsSystemWindows="true"> 

       <android.support.design.widget.CollapsingToolbarLayout 
        android:id="@+id/collapsing_toolbar" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:fitsSystemWindows="true" 
        app:contentScrim="?attr/colorPrimary" 
        app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

        <android.support.v4.view.ViewPager 
        android:id="@+id/issue_browse_view_pager" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
       app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

        <android.support.v7.widget.Toolbar 
         android:id="@+id/toolbar" 
         style="@style/ToolBarStyle" 
         android:layout_width="match_parent" 
         android:layout_height="?attr/actionBarSize" 
         app:layout_collapseMode="pin" 
         app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
         app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

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

      </android.support.design.widget.AppBarLayout> 
Verwandte Themen