13
我剛剛用CoordinatorLayout嘗試了新的支持設計庫,但是我遇到了錨定子視圖的問題。我的佈局目前看起來是這樣的:CoordinatorLayout layout_anchor不起作用
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<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/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="enterAlways" />
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/toolbar"
app:layout_anchorGravity="bottom"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:src="@drawable/ic_fab_add"
android:onClick="onAddPlayerClick"
android:layout_gravity="bottom|end"
app:elevation="4dp"
app:borderWidth="0dp"/>
當加載RecyclerView列表中,第一項是由操作欄重疊。我假設應用程序:layout_anchor無法正常工作。我已經嘗試將它錨定到appbar,但沒有成功。
有沒有人知道我在做什麼錯在這裏?
阿使用
app:layout_behavior
爲什麼我真的想念那個?...非常感謝您much.Problem解決。 –'@ string/appbar_scrolling_view_behavior'的值是什麼?爲什麼添加這個行爲有效? – AdamMc331
我也想知道這個以及 – Eenvincible