相关疑难解决方法(0)

CoordinatorLayout、FAB 和容器布局冲突

我有一个抽屉的主要活动,其中有一个container layout我将每个片段替换为FragmentManager.

我想向我的一个子片段添加一个 FAB,该片段在滚动时隐藏/显示,但我不确定我做错了什么并得到:

在此处输入图片说明

布局:

<?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"
  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:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="?actionBarSize"
      android:minHeight="?actionBarSize"
      android:theme="@style/Toolbar"
      app:layout_scrollFlags="scroll|enterAlways" />

  </android.support.design.widget.AppBarLayout>

  <FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

  <android.support.design.widget.FloatingActionButton
    style="@style/Widget.Design.FloatingActionButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right|end"
    android:layout_marginBottom="@dimen/spacing_medium"
    android:layout_marginRight="@dimen/spacing_medium"
    android:elevation="@dimen/elevation_little"
    app:fabSize="normal"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    app:srcCompat="@drawable/ic_add_white_18dp" />

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android android-fragments material-design floating-action-button android-coordinatorlayout

3
推荐指数
1
解决办法
5327
查看次数