• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

SurfaceView 顶部的按钮,在 Android setZOrderOnTop 设置为 true

用户头像
it1352
帮助1

问题说明

我在一个应用中有两个表面视图,一个表面视图需要与另一个表面视图重叠.例如,假设有两个表面视图 SurfaceView A 和 SurfaceView B.B 需要在 A 之上,这是通过在 B 上设置 setZOrderOnTop(true) 来实现的.

I have two surfaceviews in an app and one surfaceview needs to overlap the other surfaceview. For example, say there are two surfaceviews SurfaceView A and SurfaceView B. B needs to be on top of A which is accomplished by setting setZOrderOnTop(true) on B.

现在,我想在 B 的顶部显示一些文本或按钮,但因为它的 Z 顺序设置为 true,所以添加的文本或按钮不会显示在顶部,而是位于其下方.如果未设置 setZOrderOnTop 属性,则文本视图和按钮确实显示在顶部,但 B 不会与 A 重叠.

Now, I want to display some text or buttons on top of B but because it has Z order set as true the text or buttons added doesn't show on top but come underneath it. If the setZOrderOnTop property is not set then the text views and buttons does show up on top but then B doesn't overlap A.

我已经尝试将 SurfaceView B 和 textview 或按钮放在 FrameLayout 中,但它仍然出现在 B 下.有没有办法可以将 z order 设置为 true 并且仍然可以将文本或按钮放在上面?

I have tried placing SurfaceView B and the textview or buttons in FrameLayout but still it appears under B. Is there a way that z order can be set to true and still text or buttons can come on top of it?

正确答案

#1

我能够通过使用 setZOrderMediaOverlay(true) 而不是 setZOrderOnTop 来解决这个问题.

I was able to resolve the issue by using setZOrderMediaOverlay(true) instead of setZOrderOnTop.

方法 setZOrderOnTop 如果设置为 true 将始终位于窗口顶部.因此,为了在表面视图上叠加视图,应该使用 setZOrderMediaOverlay.

The method setZOrderOnTop if set to true will always be on top of the window. So, in order to have overlay view over surface view setZOrderMediaOverlay should be used.

有关详细信息,请参阅此处的 setZOrderMediaOverlay 文档.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfhaek
系列文章
更多 icon
同类精品
更多 icon
继续加载