android - 上下移动 float 操作按钮以避免被 snackbar 挡住

标签 android floating floating-action-button

我正在使用 this library实现 float 操作栏,当屏幕上出现 snackbar 时,我似乎找不到移动按钮的方法。那个图书馆甚至有可能吗?

最佳答案

对于任何在未来寻找答案的人..

Coordinator Layout 作为 Floating Action Button 的 Parent Layout 会自动为你处理动画效果。

float 操作按钮有一个默认行为,它会检测到正在添加的 Snackbar View ,并相应地在 Snackbar 的高度上方为按钮设置动画。

Floating Action Button Behavior

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/clayout">
<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:layout_marginBottom="16dp"
    android:layout_marginRight="16dp"
    android:src="@drawable/filter_icon"
    app:rippleColor="@color/colorGray"
    app:fabSize="normal"
    app:borderWidth="0dp"/>
</android.support.design.widget.CoordinatorLayout>

然后我们的 SnackBar 代码将使用 Coordinatorlayout[here layout] 作为父布局,如下所示:

Snackbar.make(clayout, "Click on row to know more details", Snackbar.LENGTH_LONG)
                    .setAction("OK", new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {

                        }
                    }).show();

关于android - 上下移动 float 操作按钮以避免被 snackbar 挡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27912656/

相关文章:

java - 指定的子级已经有一个父级 - 实现 FloatingActionMenu

java - 用于关闭对话框的按钮引发 nullpointerException

android - firebase createUserWithEmailAndPassword 在 android 中不起作用

html - 控制两个 float div的宽度以相反的顺序显示,无论div中内容的宽度如何

java - 如何创建像 Clipboard Pro App 这样的 float 窗口?

javascript - 打开和关闭浮层同一个链接?

android - float 操作按钮 : Setting a custom background is not supported

android - 如何在 float 操作按钮的背景中设置图像而不是 android 中的颜色?

android通知点击不工作

android - 如何按字符串名称打开 fragment ?