android 4.0中如何去掉全局的虚拟导航栏

2025-03-15 01:21:38
推荐回答(1个)
回答1:

在android\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\tablet\
下的TabletStatusBar.java的 addStatusBarWindow() 函数中
WindowManagerImpl.getDefault().addView(sb, lp); 这句话是就是在把sb 加入到window中
屏蔽掉这句就行了
或者WindowManagerImpl.getDefault().removeView(sb); 也可以移除 其中sb就是 SystemUI的
View , addStatusBarWindow()全部代码如下:

final View sb = makeStatusBarView();

Log.w("____________" , "addStatusBarWindow");

final WindowManager.LayoutParams lp = new
WindowManager.LayoutParams(

ViewGroup.LayoutParams.MATCH_PARENT,

ViewGroup.LayoutParams.MATCH_PARENT,

WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,

WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING
|
WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
// We use a
pixel format of RGB565 for the status bar to save memory bandwidth
and
// to ensure that the layer can be handled by
HWComposer. On some devices the
// HWComposer is unable to
handle SW-rendered RGBX_8888 layers.
PixelFormat.RGB_565);

// We explicitly leave FLAG_HARDWARE_ACCELERATED out of the flags.
The status bar occupies
// very little screen real-estate and is
updated fairly frequently. By using CPU rendering
// for the status
bar, we prevent the GPU from having to wake up just to do these small

// updates, which should help keep power consumption down.

// lp.gravity = getStatusBarGravity();

lp.setTitle("SystemBar");
lp.packageName =
mContext.getPackageName();
WindowManagerImpl.getDefault().addView(sb,
lp);

// Log.w("______________" ,
"removeView(sb)");
// WindowManagerImpl.getDefault().removeView(sb);