Android - 如何在2个布局之间放置fab-menu(来自yavski库)

时间:2016-07-18 21:16:09

标签: android android-studio layout floating-action-button

我正在使用yavski library的浮动操作菜单,我尝试将其置于2个布局之间,就像在this问题中一样:

但是当我用yavski图书馆的fab菜单做的时候,它没有用......

我该怎么办?

修改

我在标题和“cardview”(link)之间添加了按钮。

enter image description here

当我向下滑动并使用默认库进行制作时,它运行良好(按钮消失并在向上滑动时出现)。但是当我使用特殊的那个时,它在开始时看起来很好,但是当我向下滑动时,它不会消失而是滑下来......

enter image description here

最后一个问题是,当点击按钮时,它会向上移动一点......

enter image description here

1 个答案:

答案 0 :(得分:0)

“一个简单的图书馆与FAB +结合在一起......”

我不使用你提到的这个特殊的库,但是使用默认的库,它就像这样工作,如果创建投影的人工作得很好,那么它应该也是:

 <android.support.design.widget.CoordinatorLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:background="@color/white">

                    //Content

                </LinearLayout>

                <android.support.design.widget.FloatingActionButton
                    android:id="@+id/fab"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="16dp"
                    android:clickable="true"
                    android:onClick="process"
                    android:src="@drawable/ic_add"
                    app:layout_anchor="@id/ANCHOR_VIEW"
                    app:layout_anchorGravity="bottom|right|end"
                    app:backgroundTint="@color/accent"/>

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