3

AppbarLayout内のCollapsingToolbarLayoutの上に静的ビューを配置するにはどうすればよいですか?私のコーディネータービュー内の組織は次のようになります。CollapseingToolbarLayoutの上にビューを配置する方法

<AppBarLayout> 
    <RelativeLayout/>    ----- should not collapse 
    <CollapsingToolbarLayout/> ----- should collapse 
</AppBarLayout> 
<NestedScrollView/> 

問題は、私はCollapsingToolbarの上に何かを追加するとき、彼らは大丈夫現れるが、CollapsingToolbarの崩壊機能を壊す、ということです。

完全なXML:

<?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:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="c.toolbar_test.ScrollingActivity2"> 

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

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:id="@+id/button"/> 
    </RelativeLayout> 

    <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.design.widget.CollapsingToolbarLayout> 
</android.support.design.widget.AppBarLayout> 

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



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

だから私は崩壊し、ツールバー上の一部のコンテンツを持っているし、まだ崩壊機能を保持することができますか?

+0

は、内部のレイアウトを入れてlayout_collapseModeが設定されていないCollapsingToolbarLayout。 – arjunkn

+0

これでもレイアウトが崩れます。 – ravindu1024

答えて

0

その遅すぎるが、HERESに何ができるか解決策 リニアとして親のレイアウトを取り、あなたの相対的なビューそのimmidiate子を配置して、あなたが望むようコーディネーターのレイアウトを追加することです....

関連する問題