Full screen surface view hides diner

I need help figuring out what is wrong with my Snackbars (Design Support) that are not showing.

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

Layout File:

<?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 a 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 a diner, it does not appear. However, when I remove the VideoView from my layout, it displays without any problems.

So, I think the VideoView is hiding it, or the diner is shown outside. To test this, I replaced VideoView with a basic view of the same size. But there I see snacks.

Has anyone else had a similar issue with SurfaceViews related to Snackbars?

+5
source share
3 answers

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

+3
source

Attach a snack bar to your VideoView instead of CoordinatorLayout

+1
source

I have a similar problem, when using WebView in Fullscreen and AppCompat, Snackbar is hiding. My solution to the problem:

• Launch the diner.

 View rootView = super.findViewById(R.id.mainContainer); Snackbar snack = Snackbar.make(rootView, message, Snackbar.LENGTH_INDEFINITE); snack.setAction("OK", callback); View view = snack.getView(); 

• Important for showing the foreground snack.

 view.requestFocusFromTouch(); 

• Set up and show off snacks. (! Important: setting this from below will hide its overlay.

 FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams(); params.setGravity(Gravity.TOP); view.setLayoutParams(params); snack.show(); 
0
source

Source: https://habr.com/ru/post/1244967/


All Articles