Kar*_*nan 16 android viewgroup android-windowmanager android-activity
这是我的代码:
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mTopView = (ViewGroup) inflater.inflate(R.layout.activity_invisible, null);
params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_DIM_BEHIND
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_FULLSCREEN;
if (keep==true) {
int value = brightnessIntent.getExtras().getInt("value");
float v=value/255.0f;
params.dimAmount=0;
params.alpha=v;
rl = (RelativeLayout) mTopView.findViewById(R.id.window);
getWindow().setAttributes(params);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
wm.addView(mTopView, params);
}
Run Code Online (Sandbox Code Playgroud)
视图仍显示状态栏,mTopView是一个叠加窗口.如何让覆盖窗口覆盖整个屏幕?我不想"隐藏"状态栏,我希望我的活动叠加到它上面.
[编辑] 强调文字
我已经在我的onCreate()方法中有这个:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
我的清单定义了一个全屏的风格.
SCREENSHOTS
这是目前的情况,我希望叠加层也扩展到状态栏.
Kar*_*nan 19
我所要做的就是这个
params.flags=WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN| and the rest
这会将覆盖视图扩展到状态栏上.
小智 6
此代码来自"Android Application 4 Development".你必须处理不同的Android版本
// Hiding the Action Bar for different android versions
if (Build.VERSION.SDK_INT < 16) {
// Hide the Action Bar on Android 4.0 and Lower
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}else {
// Hide the Action Bar on Android 4.1 and Higher
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
android.app.ActionBar actionBar = getActionBar();
actionBar.hide();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27993 次 |
| 最近记录: |