如何使surfaceview透明 [英] how to make surfaceview transparent

查看:126
本文介绍了如何使surfaceview透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好所有我想我DrawingSurface视图透明。我尝试了很多事情,但它不工作。

下面是我的xml code,使我的表面观透明

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:方向=垂直>

    <的FrameLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT>

        < ImageView的
            机器人:ID =@ + ID / imageView1
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:SRC =@可绘制/图标>
        < / ImageView的>

        <的LinearLayout
            机器人:ID =@ + ID / linearLayout1
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:后台=#00000000>

            < codewalla.android.drawings.DrawingSurface
                机器人:ID =@ + ID / drawingSurface
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =FILL_PARENT>
            < / codewalla.android.drawings.DrawingSurface>
        < / LinearLayout中>
    < /的FrameLayout>

    <的LinearLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=横向>

        <按钮
            机器人:ID =@ + ID / colorRedBtn
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =10
            机器人:的onClick =的onClick
            机器人:文本=R/>

        <按钮
            机器人:ID =@ + ID / colorBlueBtn
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =10
            机器人:的onClick =的onClick
            机器人:文本=G/>

        <按钮
            机器人:ID =@ + ID / colorGreenBtn
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =10
            机器人:的onClick =的onClick
            机器人:文本=B/>

        <按钮
            机器人:ID =@ + ID / undoBtn
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =10
            机器人:的onClick =的onClick
            机器人:文本=U/>

        <按钮
            机器人:ID =@ + ID / redoBtn
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =10
            机器人:的onClick =的onClick
            机器人:文本=R/>
    < / LinearLayout中>

< / RelativeLayout的>
 

解决方案

在构造函数中试试这个:

  SurfaceView sfvTrack =(SurfaceView)findViewById(R.id.sfvTrack);
sfvTrack.setZOrderOnTop(真正的); // 必要
SurfaceHolder sfhTrackHolder = sfvTrack.getHolder();
sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);
 

Hello all i want to make my DrawingSurface view transparent. i tried many thing but it's not working.

Here is my xml code to make my surface view transparent

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:src="@drawable/icon" >
        </ImageView>

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#00000000" >

            <codewalla.android.drawings.DrawingSurface
                android:id="@+id/drawingSurface"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
            </codewalla.android.drawings.DrawingSurface>
        </LinearLayout>
    </FrameLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/colorRedBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="R" />

        <Button
            android:id="@+id/colorBlueBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="G" />

        <Button
            android:id="@+id/colorGreenBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="B" />

        <Button
            android:id="@+id/undoBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="U" />

        <Button
            android:id="@+id/redoBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="R" />
    </LinearLayout>

</RelativeLayout>

解决方案

Try this in the constructor:

SurfaceView sfvTrack = (SurfaceView)findViewById(R.id.sfvTrack);
sfvTrack.setZOrderOnTop(true);    // necessary
SurfaceHolder sfhTrackHolder = sfvTrack.getHolder();
sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);

这篇关于如何使surfaceview透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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