How to hide the notification bar, but allow drag and drop on top?

Is it possible to hide the notification panel, as in a full-screen application, but allow the user to drag it on top?

+4
source share
3 answers
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.NAME_OF_YOUR_ACTIVITY); getSupportActionBar().hide(); 

Put this code in your java activity and replace "NAME_OF_YOUR_ACTIVITY" with what your full-screen activity is.

+1
source

There is no such SDK support for this, but you can do it with a bit of workaround coding.

You can use WindowManager to insert an opaque floating right view at the top of the screen that matches the rest of your layout and looks like part of it.

Make sure your input view is set to ignore touch events and pass them to anything below it. This should allow users to drag the notification bar, without actually keeping it visible on the screen. Well, it is still visible, just closed by your floating view.

Keep in mind that this requires that your activity topic is not populated.

0
source

Yes, maybe just enter the code below into your activity.

  @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); View view = getWindow().getDecorView(); if (hasFocus) { view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION ); } } 

In one of the β€œMy User Camera” applications, I used this, which shows a full-screen camera with a notification bar without a title, and when you drag it on top, it will show you.
Happy Coding ... :)

0
source

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


All Articles