我创建了自己的View(我在Canvas上绘制),我想在它上面制作另一个Layer(带按钮等)。我怎样才能做到这一点?
答案 0 :(得分: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?