简体   繁体   English

如何在不使用setZOrderOnTop(true)函数的情况下使SurfaceView的背景透明?

[英]How to make SurfaceView's background transparent without using function setZOrderOnTop(true)?

I'm programming a turntable game view by LuckyPan from github . 我正在从LuckyPan编程转盘游戏视图。 As you see, it extends a SurfaceView . 如您所见,它扩展了SurfaceView

And here is my problem: 这是我的问题:

  1. I need a background below turntable with picture, it means I need a SurfaceView which has a transparent background; 我需要一个带有图片的转盘下方的背景,这意味着我需要一个具有透明背景的SurfaceView
  2. setZOrderOnTop(true) — I found it to make a transparent background, but it made SurfaceView above everything in the APP; setZOrderOnTop(true) —我发现它可以使背景透明,但它使SurfaceView高于APP中的所有内容;
  3. Now when I run app in a short phone, the turntable will above the "bottom tab" which is at the bottom of the screen. 现在,当我在短电话中运行应用程序时,转盘将位于屏幕底部的“底部选项卡”上方。

So, does anyone has a way can do one of these: Make SurfaceView have a transparent background without using setZOrderOnTop(true) . 因此,是否有人可以执行以下操作之一:使SurfaceView具有透明背景,而无需使用setZOrderOnTop(true)

OR 要么

Set a view above the SurfaceView which have already calling setZOrderOnTop(true) . SurfaceView上方设置已经调用setZOrderOnTop(true)的视图。

Is this a bug of the SurfaceView that always has a not transparent background unless using the setZOrderOnTop(true) ? 这是SurfaceView的错误,除非使用setZOrderOnTop(true)否则该错误始终具有不透明的背景? If it is, why google hasn't fix it for more than ten years? 如果是这样,为什么Google十多年没有修复它? Or is there something I missed? 还是我错过了什么? Thanks for helping. 感谢您的帮助。

Make SurfaceView have a transparent background without using setZOrderOnTop(true) 使SurfaceView具有透明背景而不使用setZOrderOnTop(true)

surface.setBackgroundColor(resources.getColor(R.color.transparent))

Forgot: transparent this is a color value in a colors.xml which holds a value "#0000000" 忘记了:透明的,这是colors.xml中的颜色值,其中包含值“#0000000”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM