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?
try adding, videoView.setZOrderOnTop(false); in your java file.
Attach the snack bar to your VideoView instead of CoordinatorLayout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With