Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display view above status bar?

I recently saw an image of an app that was capable of displaying a view above the status bar and was also able to cover it with a view.

I know you can get a view right below the status bar from a view with align parent top. But how would you get a view on top of the status bar??

Example

like image 609
user1190019 Avatar asked Mar 22 '12 03:03

user1190019


People also ask

What is display shown on the status bar?

A status bar is an area at the bottom of a primary window that displays information about the current window's state (such as what is being viewed and how), background tasks (such as printing, scanning, and formatting), or other contextual information (such as selection and keyboard state).

How do I change my status bar appearance?

To customize it, first pull down the slider bar from the top of the screen. Next, tap on the three vertical dots in the top right corner. Now click on Status bar. You're in.

Where is the status bar display?

The status bar is the area at the bottom of the window that contains Help text and coordinate information.

Is status bar is at the top of the screen?

A status bar appears along the upper edge of the screen and displays information about the device's current state, like the time, cellular carrier, and battery level.


1 Answers

Disable the System Status Bar - Without Root


After two full days of searching through SO posts and reading the Android docs over and over.. Here is the solution that I came up with. (tested)

    mView= new TextView(this);                                       
    mView.setText(".........................................................................");                       

    mLP = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            100,
            // Allows the view to be on top of the StatusBar
            WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
            // Keeps the button presses from going to the background window
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
            // Enables the notification to recieve touch events
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
            // Draws over status bar
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);

    mLP.gravity =  Gravity.TOP|Gravity.CENTER;      

    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    mWindowManager.addView(mView, mLP);

Dont forget the permissions:

<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />

Note:
Tested upto kitkat.

like image 179
amalBit Avatar answered Oct 18 '22 14:10

amalBit