[Android TV]setZOrderMediaOverlay 调整surfaceView Z-Order使用发现
2016-08-17 18:24
761 查看
最近使用了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).
看翻译貌似是:把该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理清,现在先以此记下此事!
需要对四个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理清,现在先以此记下此事!
相关文章推荐
- Android MVP 利用rxjava 避免向Model传入监听方法
- android开发中联系人列表显示字母索引
- Android简易实战教程--第十八话《ListView显示,简单的适配器SimpleAdapter》
- Android简易实战教程--第十八话《ListView显示,简单的适配器SimpleAdapter》
- androidStudio导入工程
- Android 使用Toolbar制作标题栏-design
- android 广播的方法
- [Android Studio] Gradle项目中添加JNI生成文件(.so文件)
- android 倒计时 发送激活码
- 用gradle手动编译出android的简单的apk文件(gradle学习之路二)
- Android Studio上传lib到Jcenter(记录)
- 关于百度地图Android
- 在android布局中使用include和merge标签
- Android—NDK环境搭建及JNI使用详解
- 近百个Android优秀开源项目,覆盖Android开发的每个领域
- Android传递参数总结
- RXAndroid之RxSharedPreference的使用
- 安卓事件分发机制之简明教程
- 分享Android中Toast的自定义使用
- Android5.1源码改变USB连接方式