2012-09-17 59 views
2

我尋找一種方法,把像SwipePad 了Android通知欄上方觀察這就是我想要的(紅色恐慌): enter image description here添加鑑於上述通知欄

我有測試此代碼:

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); 

但這只是給我:enter image description here

綠色條是不是上面的通知欄...

任何人都可以給我這個好方法嗎?

+1

檢查這個帖子http://stackoverflow.com/questions/11498366/create-a-ui-or-a-widget-that-sees-on-top-of-all-application-in-android – nandeesh

+0

太棒了! !正是我需要的!你能否回答我會接受:D 非常感謝! – jaumard

回答