2

I search a way to put a view above the android notification bar like SwipePad This is what i want (red scare) : enter image description here

I have test this code :

    setContentView(R.layout.main);

    View disableStatusBar = new View(this);
    disableStatusBar.setBackgroundColor(Color.GREEN);

    WindowManager.LayoutParams handleParams = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.FILL_PARENT,
        50,
        // This allows the view to be displayed over the status bar
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,//or other type_system make same
        // this is to keep button presses going to the background window
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
        // this is to enable the notification to recieve touch events
        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
        // Draws over status bar
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
        PixelFormat.TRANSLUCENT);

    handleParams.gravity = Gravity.TOP;
    getWindow().addContentView(disableStatusBar, handleParams);

But this only give me : enter image description here

Green bar are not above notification bar...

Anyone can give me the good way ?

jaumard
  • 8,202
  • 3
  • 40
  • 63
  • 1
    check this post http://stackoverflow.com/questions/11498366/create-a-ui-or-a-widget-that-sees-on-top-of-all-application-in-android – nandeesh Sep 17 '12 at 19:56
  • Great !!! Exactly what i need !!! Can you put it on answer i will accept it :D Thanks a lot !! – jaumard Sep 17 '12 at 21:21

2 Answers2

0

I use this solution :

 final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            |WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            PixelFormat.TRANSLUCENT);
vuhoanghiep1993
  • 715
  • 1
  • 8
  • 15
-3

If you mean you want an icon in the notification bar, you can probably the use the NotificationManager class.

aymeric
  • 3,877
  • 2
  • 28
  • 42
Colin
  • 25
  • 4