设置表面视图的背景色 [英] Set Background color of Surface View

查看:112
本文介绍了设置表面视图的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为相机的表面视图设置背景颜色.

I want to set a background color to the surface view to my camera surface view.

我正在使用来实现相同的.但是这个例子是不完整的.任何人都可以通过其他有用的链接来帮助我.

I am using this for implementing the same. But this example is not complete. Can anyone please help me with some other useful link.

谢谢

推荐答案

有一种解决方法.

  1. 为表面视图添加父视图组,将背景色设置为该视图组而不是表面视图;

  1. add a parent viewgroup for the surfaceview, set the background color to this viewgroup instead of the surfaceview;

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_blue_dark">

    <com.example.surfacetest.MySurface
        android:id="@+id/surface"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</FrameLayout>

  • 为SurfaceView实例添加以下内容;

  • add the following for the SurfaceView instance;

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

  • 现在,您获得了想要的背景色,并且表面视图变得透明.

    Now you get the background color you want and the surfaceview is tanslucent.

    这篇关于设置表面视图的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆