我想创建一个带有可折叠应用栏的布局,如此
---------------------
<- My activity (pinned)
---------------------
Some text and image
that may go (collapse paralax)
multiline
---------------------
Some fixed text (pinned)
----------------------
Recylcer view
-----------------------
我在网上看到的所有例子都涉及折叠视图是一个图像,因此它是一个已知的大小。我想折叠具有动态高度的自定义布局。设置为包装内容会导致折叠不起作用。使用固定高度会使折叠工作崩溃,但我不知道在设计时使用什么值。
当CollapsingToolbarLayout具有动态高度时,是否有办法让协调器布局折叠其中的视图。
Xml布局供参考:
(注意我只是将文本视图作为可折叠视图放入,但它是一个带有文本和图像的更复杂的布局)
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<TextView
android:layout_width="match_parent"
android:layout_height="100dp" <---- this is where i need wrap content, but it dont collapse untill a value is hard coded
android:textAppearance="@style/TtlTextAppearance.Large"
android:text="A very very long long sting indeed with loads of content that wont fit "
app:layout_collapseMode="parallax"/>
</android.support.design.widget.CollapsingToolbarLayout>
<include
android:id="@+id/journey_header"
layout="@layout/int_journey_header"
android:layout_below="@id/fares_list_actionbar_extension"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"
app:layout_collapseMode="pin"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<RelativeLayout
android:id="@+id/mainBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible">
<android.support.v7.widget.RecyclerView
android:id="@+id/search_results_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/return_widget"
android:visibility="visible" />
<include
android:id="@+id/return_widget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"
tools:visibility="visible" />
</RelativeLayout>
<include
android:id="@+id/list_progress"
layout="@layout/progress_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>