[Android TV]setZOrderMediaOverlay 调整surfaceView Z-Order使用发现

博客内容探讨了在Android TV应用中使用setZOrderMediaOverlay调整SurfaceView Z-Order时遇到的反直觉现象。添加View的顺序与Z-Order顺序相反,并且调用setZOrderMediaOverlay(true)后,View的Z-Order排列出现意外。作者推测可能setZOrderMediaOverlay内部存在排序机制,并计划后续查看源码以求深入理解。
部署运行你感兴趣的模型镜像

最近使用了dual decode ,并且dual subtitle.

需要对四个surfaceview进行排序。

好奇怪!

addView的顺序和Z-Order的顺序相反,

即 addView(subtitleView0), addView(videoView1), addView(subtitleView2),addView(videoView3)。

然后dumpsys surfaceFlinger 发现:

Z-Order从小到大排序为:videoView3< subtitleView2< videoView1< subtitleView0。 

如果把Z-Order比喻成一座塔的话,就是说先addView进去的就在塔上面,后面addView的在塔下面,因为塔门就在一楼嘛。

然后更奇怪的来了。

我的code是这样:

先addView(subtitleView0),addView(videoView1),然后addView(subtitleView2),然后在这里Call subtitleView2.setZOrderMediaOverlay(true);

接着addView(videoView3),然后在这里Call videoView3.setZOrderMediaOverlay(true);

最后Z-Order 从小到大排序为: videoView1< subtitleView0 < videoView3 < subtitleView2;

奇怪不?其实可能不奇怪。

先来看setZOrderMediaOverlay API说明

Android.Views.SurfaceView.SetZOrderMediaOverlay Method
Control whether the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself).
Syntax
[Android.Runtime.Register("setZOrderMediaOverlay", "(Z)V", "GetSetZOrderMediaOverlay_ZHandler")]
public virtual void SetZOrderMediaOverlay (bool isMediaOverlay)
Parameters
isMediaOverlay
Documentation for this section has not yet been entered.
Remarks
Control whether the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself). 
This is typically used to place overlays on top of an underlying media surface view.
Note that this must be set before the surface view's containing window is attached to the window manager.
Calling this overrides any previous call to SurfaceView.SetZOrderOnTop(bool).

看翻译貌似是:把该sufaceview置于其余surfaceview的最上方

但这里奇怪点有三

(0)就是addView的顺序和Z-Order的顺序,可能要看source code,不知道原生的是不是被内部人改了。

(1)我在addView后面使用setZOrderMediaOverlay (true) 也生效!

(2)就是上面排序的地方,对videoView3使用setZOrderMediaOverlay(true),其竟然还是排在第二位!


所以这里在没有追踪source code的情况下猜测:setZOrderMediaOverlay (true)里面也有个排序机制,使用setZOrderMediaOverlay(true)的,只能排在之前使用过setZOrderMediaOverlay(true)的View的下方,这样才能说得过去吧。。QAQ

后面有时间看下source code理清,现在先以此记下此事!

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值