【发布时间】:2016-12-02 12:19:52
【问题描述】:
我已经开始研究 Android 材料设计支持库,作为一个新手,我有一些困惑。而且,需要你的帮助。 :)
1) 是否可以将 layout_scrollFlags="scroll|enterAlways" 与 LinearLayout 一起使用?
2) 我想要一个位于工具栏下方的 LinearLayout。我使用 AppBarLayout 实现了它,但我想在滚动 LinearLayout 下面的内容时滚动 LinearLayout 而不是 Toolbar。在 LinearLayout 上使用 layout_scrollFlags="scroll|enterAlways" 不起作用。
3) 我们可以在 CoordinatorLAyout 中使用多个 AppBarLayout 和在 AppBarLayout 中使用 Toolbar 吗?
<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">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
app:layout_scrollFlags="scroll|enterAlways">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView : 1 " />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView : 2" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView : 3" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView : 4" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView : 5" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView : 6" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView : 7" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
在实施了 SaravInfern 的解决方案后,这是我目前所取得的成果...
【问题讨论】:
标签: android android-layout material-design android-coordinatorlayout