2016-04-06 29 views
0

Varsayılan şablonda gördüğünüz gibi daraltma araç çubuğu efekti olmasını istediğim özel bir ana ayrıntı akışı var. Onu işe almak için yuvalamayı anlamıyorum.Parçalanmış öğe tabanlı bir düzen içeren bir daraltma araç çubuğu kullanma

My etkinlik iki versiyonu vardır:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:baselineAligned="false" 
    android:divider="?android:attr/dividerHorizontal" 
    android:orientation="horizontal" 
    tools:context="com.example.android.sunshine.app.MainActivity"> 

    <!-- 
    This layout is a two-pane layout for the Items master/detail flow. 
    --> 

    <fragment 
     android:id="@+id/fragment_main" 
     android:name="xyz.selfenrichment.robertotomas.three_two_one_rotate.MainFragment" 
     android:tag="@string/tag_gridview_one_column" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="3" 
     tools:context="xyz.selfenrichment.robertotomas.three_two_one_rotate.MainFragment" 
     tools:layout="@layout/fragment_main" /> 

    <FrameLayout 
     android:id="@+id/fragmentcontainer_detail" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="2" 
     tools:layout="@layout/fragment_detail" /> 

</LinearLayout> 

tek bir panel

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/fragment_main" 
    android:name="xyz.selfenrichment.robertotomas.three_two_one_rotate.MainFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:tag="@string/tag_gridview_two_columns" 
    tools:context="xyz.selfenrichment.robertotomas.three_two_one_rotate.MainFragment" 
    tools:layout="@android:layout/list_content" /> 

akış masterdetail Ve inanıyorum benim çöken araç çubuğu olması gerektiği gibi: Şimdi

<android.support.design.widget.CoordinatorLayout ... 
... 
    <android.support.design.widget.AppBarLayout ... 
    ... 
     <android.support.design.widget.CollapsingToolbarLayout ... 
     ... 
      <android.support.v7.widget.Toolbar 

, Ben iki birleştirmek ve benzeri, düzen davranışı eklemek zorunda:

ana ayrıntı

<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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="xyz.selfenrichment.robertotomas.popularmovies.PosterBoardActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/app_bar_height" 
     android:fitsSystemWindows="true" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

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

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/AppTheme.PopupOverlay" /> 

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

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:baselineAligned="false" 
     android:divider="?android:attr/dividerHorizontal" 
     android:orientation="horizontal" 
     tools:context="com.example.android.sunshine.app.MainActivity" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <!-- 
     This layout is a two-pane layout for the Items master/detail flow. 
     --> 

     <fragment 
      android:id="@+id/fragment_main" 
      android:name="xyz.selfenrichment.robertotomas.popularmovies.MainFragment" 
      android:tag="@string/tag_gridview_one_column" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="3" 
      tools:context="xyz.selfenrichment.robertotomas.popularmovies.MainFragment" 
      tools:layout="@layout/fragment_main" /> 

     <FrameLayout 
      android:id="@+id/fragmentcontainer_detail" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="2" 
      tools:layout="@layout/fragment_detail" /> 

    </LinearLayout> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_menu_manage" 
     app:layout_anchor="@id/app_bar" 
     app:layout_anchorGravity="bottom|end" /> 

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

akmaya Ama yapmak ya da (fragment etikete veya altta yatan parçası xml düzeni davranışı eklerseniz her iki):

<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/grid_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:horizontalSpacing="10dp" 
    android:verticalSpacing="10dp" 
    android:stretchMode="columnWidth" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

Her iki durumda da farketmez, grileşme kaydırması araç çubuğunu daraltmaz.

düzenleme: Bu özellikle kafa karıştırıcı, görünüşe göre işe yarayan oldukça benzer bir örnek olan here göründüğünden.

cevap

1

Woohoo :) Onu buldum. Layout_behavior setini aldım, ancak veri bağdaştırıcısına eklediğim parça sınıfında şu satırları ekledim:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
     mGridView.setNestedScrollingEnabled(true); 
    }