【发布时间】:2017-03-08 06:39:31
【问题描述】:
我想在导航栏中设置颜色,但它没有覆盖。即使我设置了 FLAG_LAYOUT_IN_SCREEN 。如何在服务中设置全屏透明布局。请帮帮我? **这是我的代码:**
View mView = new View(this);
mView.setBackgroundColor(shared.getColor());
// get the WindowManager for the context-specific Display
WindowManager wm = (WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE);
// create the LayoutParams for the new Window
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,//width
WindowManager.LayoutParams.FILL_PARENT,//height
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,//xpos // TYPE_SYSTEM_ALERT is denied in apiLevel >=19
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,// flags
PixelFormat.TRANSLUCENT //formats // the pixel format, here: translucent
);
wm.addView(mView, params);
【问题讨论】:
-
一般来说,从服务中改变视图是个坏主意。很多用户认为你正在做的事情很烦人。如果你试图提醒用户,请尝试使用另一种方法。
-
你能建议我吗,还有什么其他方法可以让颜色过滤像服务一样的视图?
-
嗨@lisha,你找到解决方案了吗?
-
不,你知道解决办法吗
标签: android android-layout android-studio layout navigation