简体   繁体   中英

Transparent View with Android

I try to have a bitmap moving over my android application. I m be able to have my bitmap behind my text view, but not over them.

  public void onCreate(Bundle savedInstanceState)
...
     // ll is a FrameLayout
     ll.addView(text1);
     ll.addView(text2);
     ll.addView(new Panel(this),200,400);

my Panel class is defined like this :

    class Panel extends SurfaceView
......
 @Override
        public void onDraw(Canvas canvas) {
           canvas.drawColor(0, PorterDuff.Mode.CLEAR);
            Bitmap bitmap;
            GraphicObject.Coordinates coords;
            for (GraphicObject graphic : _graphics) {
                bitmap = graphic.getGraphic();
                coords = graphic.getCoordinates();
                canvas.drawBitmap(bitmap, coords.getX(), coords.getY(), null);
            }
        }

Can you help me ? How Can i Draw a transparent bitmap over my views of my application?

I never tried myself, but what about using this?

setForeground(Drawable drawable):
Supply a Drawable that is to be rendered on top of all of the child views in the frame layout.

The drawable should be transparent: https://developer.android.com/reference/android/graphics/drawable/ColorDrawable.html and the color might be something like #00XXXXXX as the 2 first digits are the alpha channel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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