简体   繁体   中英

Remove background colour of surface view to make it transparent

I am using curl Library by Harism in my code. I want its surface view to be transparent. we have tried the code setZOrderMediaOverlay(true), with that the image alpha maintained but with the use of this function, Our basic touch listener of curl library is not working. Please suggest. Thanks!

You can also check the below screen shot. 在此处输入图片说明

The surface view is actually BEHIND your window, and a hole punched in the window for you to see it. You thus can put things on top of it in your window, but nothing in your window can appear behind it.

http://groups.google.com/group/android-developers/browse_thread/thread/8d88ef9bb22da574

From API 5 onwards you can use setZOrderOnTop. The trick is that you have to do it in your constructor so it gets called before the view is attached to the window:

public ZenClockSurface(Context context, AttributeSet attrs) {
  super(context, attrs);

  setZOrderOnTop(true);

  SurfaceHolder holder = getHolder();
  holder.setFormat(PixelFormat.TRANSLUCENT);
}

This way you can set surface view background as Transparent. Hope this solves your problem.

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