材料设计中如何展开/折叠android组件

材料设计中如何展开/折叠android组件,android,material-design,android-support-library,Android,Material Design,Android Support Library,如何展开/折叠android组件,如ImageView,GoogleMap。。等 我正在使用设计支持库来提供android.support.Design.widget.collappingtoolbarlayout来折叠工具栏 但如何折叠其他组件。 此外,我对设计支持库没有深入的了解,如果可以使用collappingtoolbarlayout折叠组件,请给我一些示例或示例。 提前感谢。协调人布局内的视图与其他人协商,以便通过指定这些视图来有效地协同工作 协调布局是材料设计的一个超级酷的特性,有助

如何展开/折叠android组件,如
ImageView
GoogleMap
。。等 我正在使用设计支持库来提供
android.support.Design.widget.collappingtoolbarlayout
来折叠
工具栏

但如何折叠其他组件。 此外,我对设计支持库没有深入的了解,如果可以使用
collappingtoolbarlayout
折叠组件,请给我一些示例或示例。
提前感谢。

协调人布局内的视图与其他人协商,以便通过指定这些视图来有效地协同工作

协调布局是材料设计的一个超级酷的特性,有助于创建有吸引力和协调的布局

您所要做的就是将子视图包装到CoordinatorLayout中

<?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="com.byte64.coordinatorlayoutexample.ScollingActivity">

 <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" />
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

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

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

<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"
    app:layout_anchor="@id/app_bar"
    app:layout_anchorGravity="bottom|end"
    app:srcCompat="@android:drawable/ic_dialog_email" />

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

关闭:


这里有一个博客可能会有所帮助。甚至在支持设计库发布之前,就已经发布了第三方库。如果您感兴趣,可以在github上找到。感谢您提供的博客链接@Raghunandan。。。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView     
 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"
 app:layout_behavior="@string/appbar_scrolling_view_behavior"
 tools:context="com.byte64.coordinatorlayoutexample.ScollingActivity"
 tools:showIn="@layout/activity_scolling">

 <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/text_margin"
    android:text="@string/large_text" />

 </android.support.v4.widget.NestedScrollView>