【问题标题】:Android - Snackbar Cover my ViewAndroid - Snackbar 覆盖我的视野
【发布时间】:2015-11-30 09:37:49
【问题描述】:

为什么 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:从编辑历史看来,您从问题中删除了图像。
  • 没关系,我再添加一次

标签: java android


【解决方案1】:

documentation 这里说:

Snackbars 出现在屏幕上的所有其他元素之上,并且只有一个可以 一次显示。

所以,Snackbar 会像 Toast 一样覆盖您的视野。

【讨论】:

  • 不,它不应该阻止我的按钮,请看google.com/design/spec/components/…,上面写着不要阻止浮动操作按钮
  • @MinaFawzy 是的,它不会阻止浮动按钮,因为它会在显示 Snackbar 时将其向上移动一点。
  • 我的意思是一样的,它会阻止我的按钮,它不应该这样做
  • 不,不一样。您的按钮属于android.widget.Button 类,但浮动操作按钮属于android.support.design.widget.FloatingActionButtonFloatingActionButton 扩展了 ImageButton 并为其添加了浮动功能。
猜你喜欢
  • 1970-01-01
  • 2018-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-04
  • 1970-01-01
  • 2019-10-14
  • 2022-09-23
相关资源
最近更新 更多