安卓 - Snackbar覆盖了我的View

3
为什么Snackbar覆盖了我的视图
这是我的XML代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fullview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/dark_gray"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">

            <TextView
                android:id="@+id/reload"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:layout_centerInParent="true"
                android:text="@string/reload"
                android:visibility="visible" />

            <ProgressBar
                android:id="@+id/progressbar"
                style="?android:attr/progressBarStyleLarge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center"
                android:visibility="gone" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/complist"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                android:layout_gravity="center"

                android:fadeScrollbars="false" />
        </RelativeLayout>


        <LinearLayout
            android:id="@+id/buttons"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_margin="5dp"
            android:orientation="horizontal">

            <Button
                android:id="@+id/send"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:layout_weight="1"
                android:background="@color/blue"
                android:text="@string/send"
                android:textColor="@android:color/white" />

            <Button
                android:id="@+id/cancel"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:layout_weight="1"
                android:background="@color/green"
                android:text="@string/cancel"
                android:textColor="@android:color/white" />
        </LinearLayout>
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

用于显示蛇形进度条的Java代码

 private CoordinatorLayout _CoordinatorLayout;

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.compition, null);

        _CoordinatorLayout = (CoordinatorLayout) v.findViewById(R.id.fullview);

}

Snackbar.make(_CoordinatorLayout , message , Snackbar.LENGTH_LONG).show();

这里是截图

输入图片描述

我错过了什么吗?


你可以发布一下它在图片中的样子吗? - johnrao07
从编辑历史记录来看,你好像将问题中的图片删除了。 - Midhun MP
its ok I add it again - Mina Fawzy
1个回答

0

这里的文档说:

Snackbars 出现在屏幕上方,只能同时显示一个。

因此,Snackbar 会覆盖您的视图,就像 Toast 一样。


不应该阻止我的按钮,看一下这个链接:https://www.google.com/design/spec/components/snackbars-toasts.html#snackbars-toasts-usage ,它说不要阻止浮动操作按钮。 - Mina Fawzy
1
@MinaFawzy 是的,它不会阻挡浮动按钮,因为当 Snackbar 显示时,它会将其向上移动一点。 - Eric B.
我的意思是它是一样的,它阻止了我的按钮,它不应该这样做。 - Mina Fawzy
2
不,它们不一样。你的按钮属于android.widget.Button类,但是浮动操作按钮属于android.support.design.widget.FloatingActionButton类。FloatingActionButton继承了ImageButton并为其添加了浮动功能。 - Eric B.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接