开发者

Android: how to place a button at an x,y position over top of Canvas

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.


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"  
/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜