我希望這是你在找什麼:app:layout_collapseMode="parallax"
應該做的:
例的伎倆:
<?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:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:text="New Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:text="New Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:text="New Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:text="New Button" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbarCollapse"
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="?actionBarSize"
app:layout_collapseMode="pin" />
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:minHeight="190dp"
android:src="@mipmap/ic_launcher"
app:layout_collapseMode="parallax" />
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="102dp"
android:minHeight="190dp"
android:scaleType="fitXY"
android:src="@drawable/social"
app:layout_collapseMode="parallax" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
此外,你可能想看一看:app:layout_scrollFlags
標記:
http://developer.android.com/reference/android/support/design/widget/AppBarLayout.LayoutParams.html
此外,有兩個工具欄是不是一個好主意,我想你要找的TabLayout
,這樣的例子:
https://github.com/TheLittleNaruto/SupportDesignExample
我不知道TabLayout正是我需要的;我需要意識到這樣的事情:https://www.dropbox.com/s/yi9nk7b4jg4v813/2a_08.mp4?dl=0(注意2個酒吧是如何一個接一個地倒塌的) – IKIKN2
我的意思是,像上面的例子,請參閱gif:https://camo.githubusercontent.com/4e116716b3ddb76b845c5bcb588b6d69b29d4310/687474703a2f2f692e737461636b2e696d6775722e636f6d2f714b6561462e676966你應該可以添加'Toolbar'(或者本例中的'CollapsingToolbarLayout',它是一個'TabLayout'),就像這個例子: https://github.com/TheLittleNaruto/SupportDesignExample/blob/master/app/src/main/res/layout/app_container_view.xml這是你的解決方案。 – Mohsen
或者你應該在視圖中加入這個:'app:layout_collapseMode =「pin」'如果你在'CollapsingToolbarLayout'中使用這個' – Mohsen