0
我创建了自己的视图(我在画布上绘制),并且我想在其上创建另一个图层(带有按钮等)。我怎样才能做到这一点?绘制自己的自定义视图
我创建了自己的视图(我在画布上绘制),并且我想在其上创建另一个图层(带有按钮等)。我怎样才能做到这一点?绘制自己的自定义视图
创建一个FrameLayout并添加你想要的视图 - FrameLayout允许覆盖控件。
只要确保顶部有一些不透明设置,否则你将看不到它下面的控件 - 也要注意添加视图的顺序。
FrameLayout layers = new FrameLayout(this);
CustomViewBottom bottom = new CustomViewBottom(this);
CustomViewOverlay overlay = new CustomViewOverlay(this);
//the overlay class must set the ALPHA property
//of the PAINT object that it uses to draw
layers.addView(bottom);
layers.addView(overlay);
this.setContentView(layers);
How to draw an overlay on a SurfaceView used by Camera on Android?
谢谢,我会检查出来。 – mglisty 2012-08-17 11:59:33
使上层的空/非描绘区域为透明。 – 2012-08-16 11:19:18