0

I've created my own View (in which I draw on Canvas), and I want to make another Layer (with buttons etc.) on top of it. How can I do this?

mglisty
  • 151
  • 2
  • 4
  • 15

1 Answers1

0

Create a FrameLayout and add the views you want there - the FrameLayout allows for Overlaying of controls.

Just be sure that the top one has some opacity set, otherwise you won't see the controls below it - also be careful of the order you add the Views.

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?

Community
  • 1
  • 1
Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95