views:

679

answers:

1

Is it possible to place buttons at an X,Y position over the top of a Canvas?

For example, on the opening screen of my game, I would like to place buttons for "Play Now", "Instructions", etc, right on top of the canvas.

Right now, I'm looking at Touch locations on the Canvas and comparing them to various X,Y bounds. It works, but adding a button with a click listener would probably be much more efficient.

A: 

I found that if I use an AbsoluteLayout and the button XML below, it works:

<Button
android:id="@+id/button"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="Button"
android:layout_x="50px"
android:layout_y="50px"
/>

Ben Mc
If you're going to use absolute positioning, make sure to test it on all screen density types and orientations.
Christopher