Android 透明视图
我尝试让位图在我的 Android 应用程序上移动。我可以将位图放在文本视图后面,但不能放在文本视图上方。
public void onCreate(Bundle savedInstanceState)
...
// ll is a FrameLayout
ll.addView(text1);
ll.addView(text2);
ll.addView(new Panel(this),200,400);
我的面板类定义如下:
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);
}
}
你能帮助我吗?如何在应用程序的视图上绘制透明位图?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己从未尝试过,但是使用这个怎么样?
可绘制对象应该是透明的: https://developer.android.com/参考/android/graphics/drawable/ColorDrawable.html
颜色可能类似于
#00XXXXXX
,因为前 2 位数字是 Alpha 通道。I never tried myself, but what about using this?
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.