2016-01-15 64 views
-1

我改變了我的文章。我有CoordinatorLayout的問題。我並不完全掌握這個概念來創建動畫。有些幫助是值得歡迎的。Android協調員佈局

<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: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|exitUntilCollapsed"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="200dp" 
      android:background="#ff7788" 
      app:layout_collapseMode="parallax" /> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" /> 


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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     app:layout_scrollFlags="scroll|enterAlways"> 

     <LinearLayout 

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

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom|center" 
       android:text="@string/id" 
       android:textColor="@android:color/white" 
       android:textSize="30sp" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom|center" 
       android:text="@string/taille" 
       android:textColor="@android:color/white" 
       android:textSize="30sp" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom|center" 
       android:text="@string/type" 
       android:textColor="@android:color/white" 
       android:textSize="30sp" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom|center" 
       android:text="@string/condition" 
       android:textColor="@android:color/white" 
       android:textSize="30sp" /> 


     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:orientation="horizontal"> 


      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_account_box_black" /> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_account_box_black" /> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_account_box_black" /> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_account_box_black" /> 

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



    <android.support.design.widget.TabLayout 
     android:id="@+id/tabLayout" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:background="@android:color/holo_green_light" /> 

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

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

我得到這個 Image1

後滾動

Image2

藍色部分仍然是工具欄下可見。我想這部分繼續滾動,除非tabLayout到達工具欄(對不起我的英文不好)

+0

正如我所看到的,您想要完全像第一個'CollapsingToolbarLayout'這樣做意味着摺疊後,它會隱藏? – Mohsen

+0

我想要第一個CollapsingToolbarLayout摺疊後,第二個繼續滾動,以便在圖片2中,只有紅色和綠色部分可見 –

+0

我回答,請嘗試一下並讓我知道。另外,您可能想要看看:http://stackoverflow.com/a/34827861/4409113 – Mohsen

回答