简体   繁体   English

渲染脚本透明度/ alpha

[英]Renderscript transparency / alpha

I'm using ICS and trying to show a transparent Renderscript layer over a regular view. 我正在使用ICS,并试图在常规视图上显示透明的Renderscript层。 I would like to use RS to draw text on the app. 我想使用RS在应用程序上绘制文本。

I'm using the setAlpha(8, 8); 我正在使用setAlpha(8,8); and I can see that the layer generated it's BGRA (dumpsys SurfaceFlinger). 我可以看到生成该层的是BGRA(dumpsys SurfaceFlinger)。

My RS script is simply doing this: 我的RS脚本只是这样做:

rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
rsgDrawText("Hello!", 50,50);

I would like to be able to show this Renderscript layer drawing text, over my regular view. 我希望能够在我的常规视图上显示此Renderscript层的绘图文本。

My main activity uses setContentView two times, one for my main view, and second one for the RS. 我的主要活动使用setContentView两次,一次用于主视图,第二次用于RS。 Even if this approach might be wrong, I should at least be able to see the background of the app, while I only see black and the "Hello!" 即使这种方法可能是错误的,我也至少应该能够看到应用程序的背景,而我只会看到黑色和“ Hello!”。 text in white covering everything. 白色覆盖所有内容。 I also tried using two different activities, but I've never been able to make the RenderScript layer transparent. 我也尝试使用两种不同的活动,但是我从未能够使RenderScript层透明。

Any ideas? 有任何想法吗?

You also need to set the PixelFormat and ZOrder of your Renderscript view. 您还需要设置Renderscript视图的PixelFormat和ZOrder。 Try adding this when you create your Renderscript view: 创建Renderscript视图时,尝试添加以下内容:

view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
view.setZOrderOnTop(true);

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

相关问题 RenderScript 删除 bitmap 处带有 alpha 的像素 - RenderScript remove pixels with alpha at bitmap RenderScript不会修改Alpha通道吗? [Android]产品 - RenderScript does not modify alpha channel? [Android] 在listView android上设置alpha透明度 - Setting alpha transparency at a listView android 绘制透明渐变,Alpha透明度从0到1 - Draw transparent gradient with alpha transparency from 0 to 1 如何在帧中实时加入带有 alpha / 透明度的 png - How to join png with alpha / transparency in a frame in realtime 在着色器中使用alpha测试的OpenGL ES 2.0透明度 - OpenGL ES 2.0 transparency using alpha testing in shader Android自定义视图无法以正确的方式处理透明度/ alpha - Android Custom View doesn't handle transparency/alpha the right way 用于背景精灵的Android Alpha透明度无法达到预期效果 - Android alpha transparency for background sprite for fade in effect is not working as expected Android OpenGL-三角形带中的三角形的ES alpha透明度是否不同? - Android OpenGL - ES alpha transparency different for triangles in triangle strip? 如何将透明度(alpha)设置为底部菜单项kotlin - How do i set transparency(alpha) to bottom menu items kotlin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM