如何在android中浮动/重叠视图?
我有很多活动在表格布局内有滚动视图。但是,需要进行一些小的设计更改,因此我必须从上到下在整个屏幕上放置黑色透明视图。是否可以在表格布局或滚动视图中执行此操作?
I have many activities with a scrollview inside a tablelayout. However, it is necessary a small design change, so I have to put a black transparent view over the whole screen from the top to the bottom. Is it possible to do it in the tablelayout or the scrollview?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
RelativeLayout
允许轻松重叠视图。您必须调整应用程序中的现有视图,因为它不会自动执行任何操作。编辑:
执行此操作的一种快速方法是采用已组织的现有视图(
ScrollView
)并将其放入顶级RelativeLayout
中。然后,您所要做的就是在RelativeLayout 中添加新视图,并将宽度和高度均设置为MATCH_PARENT
。结果应该是黑色透明视图在ScrollView
上可见。RelativeLayout
allows for easy overlapping of views. You'll have to adjust the existing views in your app because it doesn't do anything automatically.EDIT:
A quick way to do this would be to take your existing view (the
ScrollView
) that is already organized and put it in a top-levelRelativeLayout
. Then, all you have to do is add new view inside the RelativeLayout with the width and height both set toMATCH_PARENT
. The result should be the black transparent view will be visible over theScrollView
.我通常使用 FrameLayout 来实现任何类型的视图“分层”。
正如 DeeV 所说,您可能可以以类似的方式使用relativelayout,但您可能必须在其子级上设置其他属性才能实现此目的。
I normally use FrameLayout to achieve any kind of 'layering' of views.
As DeeV said, you can probably use RelativeLayout in a similar way, but you might have to set additional attributes on its children to achieve this.