嵌入活动之间令人不快的分隔符
我有一个 ActivityGroup 嵌入了一些其他活动。但在每个嵌入式活动布局的顶部都有一个分隔符(带有阴影,就像窗口自定义标题下方一样)。
我不知道如何删除它。
Intent intent = new Intent(this, HomeLocalProductsActivity.class);
Window w = getLocalActivityManager().startActivity("LocalProducts", intent);
View dv = null == w ? null : w.getDecorView();
if (null != dv) {
((ViewGroup) findViewById(R.id.home_content_wrapper)).addView(dv);
}
这是 ActivityGroup 内的代码,用于获取子活动内容并添加它。
I have an ActivityGroup embeds some other activities. But at the top of each embedded activity layout there is a separator (with shadow, like below a window custom title).
I don't know how to remove it.
Intent intent = new Intent(this, HomeLocalProductsActivity.class);
Window w = getLocalActivityManager().startActivity("LocalProducts", intent);
View dv = null == w ? null : w.getDecorView();
if (null != dv) {
((ViewGroup) findViewById(R.id.home_content_wrapper)).addView(dv);
}
This the code inside the ActivityGroup to get the sub-activity content and add it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现这个问题 /getting-rid -of-the-gradient-at-the-top-of-an-activity-android 但它不适用于嵌入式活动。
[编辑]:我做了一个小修改(虽然不是很好,但很有效)。
每个 Activity.findViewById(id) 都会被 mGlobalWrapper.findViewById(id) 替换。在父活动中:
I found this question /getting-rid-of-the-gradient-at-the-top-of-an-activity-android but it doesn't work for embedded activity.
[edit] : I made a small hack (it's not very nice but it works).
Every Activity.findViewById(id) will be replaced by mGlobalWrapper.findViewById(id). And in the parent activity :
看起来所有嵌入活动都从其父活动组继承了样式。因此,如果您将样式应用于没有
windowContentOverlay
的活动组,如下所示:它将有效地应用于所有嵌入的活动,并且它们将摆脱烦人的阴影。不幸的是,这消除了父 Activity 的影响,这可能不适合您的应用程序。
另一种方法是侵入视图层次结构以在运行时修改嵌入活动的相关属性。使用 HierarchyViewer 进行快速检查表明,这个恼人的阴影是作为
DecorView
内的FrameLayout
的前景绘制的。FrameLayout
本身包含我们实际的用户定义布局:因此任务是在中间的这个
FrameLayout
上调用setForeground(null)
。如果我们修改 luc 的最后一个示例,它将如下所示:It looks like all embeded activities inherit their style from their parent activity group. So, if you apply a style to the activity group that has no
windowContentOverlay
, like this:It will effectively apply to all embeded activities and they'll get rid of the annoying shadow. Unfortunately, this removes the effect from the parent activity, which may not good look for your app.
Another approach is to hack into the view hierarchy to modify the relevent property of the embeded activities at runtime. A quick inspection with the HierarchyViewer shows that this annoying shadow is drawn as a foreground of a
FrameLayout
inside theDecorView
. TheFrameLayout
itself contains our actual user-defined layout:So the task is to call
setForeground(null)
on thisFrameLayout
in the middle. If we rework the last example by luc, it will look like this: