我正在尝试在我的应用程序中添加折叠工具栏,例如Google Play游戏应用程序。请帮我实现这个。
这是我的布局代码:
menu-content-open
以下是模型的链接: https://drive.google.com/file/d/0B96q57CU3elESmpsUFFBcHZaRzA/view?usp=sharing
应用链接: https://play.google.com/store/apps/details?id=com.google.android.play.games
答案 0 :(得分:0)
你可以这样使用
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/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=".activity.PlaceDetailsActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_behavior="@string/ScrollingAppBarLayoutBehavior">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:title="Results"
app:contentInsetStartWithNavigation="0dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="@dimen/anchor_point"
android:fitsSystemWindows="true"
android:background="@color/colorAccent"
app:layout_behavior="@string/BackDropBottomSheetBehavior">
</android.support.v4.view.ViewPager>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:behavior_peekHeight="@dimen/bottom_sheet_peek_height"
android:id="@+id/bottom_sheet"
app:layout_behavior="@string/BottomSheetBehaviorGoogleMapsLike"
app:anchorPoint="@dimen/anchor_point"
app:behavior_hideable="false">
<include
layout="@layout/bottom_sheet_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"/>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/bottom_sheet"
app:layout_anchorGravity="top|right|end"
android:src="@drawable/directions_white_24dp"
android:layout_margin="@dimen/fab_margin"
app:layout_behavior="@string/ScrollAwareFABBehavior"
android:clickable="true"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/merged_appbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:theme="@style/AppTheme.AppBarOverlay"
android:tag="modal-appbar"
app:layout_behavior="@string/MergedAppBarLayoutBehavior">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/colorPrimary"
android:layout_gravity="bottom"/>
<android.support.v7.widget.Toolbar
android:id="@+id/expanded_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStartWithNavigation="0dp"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/key_binding_default_toolbar_name"
app:navigationIcon="@drawable/close_white_24dp"/>
</FrameLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>