Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen surface view hides snackbar

I need some help figuring out, what's wrong with my Snackbars (Design Support), which are not showing up.

I have a VideoView (FrameLayout containing a dynamically created SurfaceView).

The layout file is:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false"
    android:id="@+id/coordinator"
    android:background="@android:color/white"
    tools:context="com.denisloh.typhoonCamera.MainActivity">

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

        <VideoView
            android:id="@+id/videoView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="top|start"
            android:background="@drawable/toolbar_gradient"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            <android.support.v7.widget.ActionMenuView
                android:id="@+id/action_bar"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content" />

        </android.support.v7.widget.Toolbar>

    </RelativeLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_camera_white_24dp" />

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

I create and show the snackbar with this snippet:

...
mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator);
...

private void showWifiSettingsSnackBar(final String message) {
    Snackbar.make(
            mCoordinatorLayout,
            getString(R.string.wifi_error_open_settings, message),
            Snackbar.LENGTH_INDEFINITE)
            .setAction(R.string.wifi_settings, new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                }
            })
            .show();
    Log.d(TAG, "Showing snackbar.");
}

When I try to open the snackbar it isn't shown. However, when I remove the VideoView from my layout, it is shown without any problems.

So, I guess, that the VideoView is hiding it or the snackbar is shown out of bounds. To check that, I replaced the VideoView with a basic View of the same size. But there, I can see the snackbars.

Did someone else had a similar issue with SurfaceViews in connection with Snackbars?

like image 407
Denis Loh Avatar asked Mar 13 '16 17:03

Denis Loh


2 Answers

try adding, videoView.setZOrderOnTop(false); in your java file.

like image 185
Brijesh Chopda Avatar answered Nov 11 '22 17:11

Brijesh Chopda


Attach the snack bar to your VideoView instead of CoordinatorLayout

like image 22
eclipse1203 Avatar answered Nov 11 '22 17:11

eclipse1203