2016-12-17 91 views

回答

0

使用这样的:

<android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     android:fitsSystemWindows="false" 
     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:expandedTitleTextAppearance="@style/TransparentText" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 


      <FrameLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:clickable="true" 
       android:foreground="?attr/selectableItemBackground" 
       android:orientation="vertical" 

       android:paddingTop="?actionBarSize" 
       app:layout_collapseMode="parallax"> 


       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:src="@drawable/test_img" 
        android:id="@+id/profile_image"> 

       </ImageView> 


      </FrameLayout> 


      <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> 

用它在你的coordinateLayout。并根据您的喜好定位您的图片。

+0

我试过这个,但它不工作,因为我喜欢。请参考这个更好的理解http://stackoverflow.com/questions/33066164/add-a-imageicon-to-the-collapsing-layout-support-library –

+1

参考这个链接:[链接] http://saulmm.github .io/mastering-coordinator 这是很好的文章坐标布局 –

+0

我需要在折叠后显示在工具栏上的图像 –