android custom view how to draw button on top of the view
I am creating a android app using LunarLander as a example. Now I need to create a few buttons which are drawn over the view. I do not want them as a seperate layout abo开发者_开发问答ve or below the view but in the custom view. Is this possible or am I going to have to programmatically show the button images then detect the touch. The buttons I create using new never show on the app. I assume this is because I have overwritten the onDraw and the buttons are never drawn even though I call super.onDraw(canvas);
I think you could use FrameLayout to show two layers - first would be your surface from lunar, and second is the layout with buttons etc. You could define everything in layout.xml file. Probably that is enough.
Regards!
If your view extends Linear/Relative/TableLayout, you can use view.bringChildToFront(child).
Use AbsoluteLayout & then in your ui thread set button.bringTioFront() & you are done! watch this post Problem when using more elements in the ListView
精彩评论