【发布时间】:2017-01-10 19:20:38
【问题描述】:
看看下面的FAB:
除非我折叠 Toolbar,否则它不会出现。这是我的 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/toolbar"
android:layout_marginTop="0dp"
android:animateLayoutChanges="true"
android:background="@android:color/white"
android:layoutDirection="locale"
android:orientation="vertical"
android:padding="0dp">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/cLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@color/accent"
android:src="@drawable/ic_add"
app:layout_anchor="@id/list"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
如果我没有为 FAB 设置任何行为,为什么会发生这种情况?我应该添加任何属性以防止这种行为吗?
【问题讨论】:
-
从顶部相对布局中删除这一行
android:layout_below="@+id/toolbar" -
并将协调器布局设为最顶层
-
@cafebabe1991 没用
-
曾经遇到过完全相同的问题,请提供您的整个布局代码。没有它解决这个问题是不可行的。
标签: android android-viewpager android-tablayout android-coordinatorlayout floating-action-button