Android的:如何放置一个按钮一个x,在画布之上y位置
问题描述:
是否有可能把按钮在一个X,在一个画布的顶部Y位置?
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.
现在,我期待在画布上的触摸位置和他们比较各种X,Y界限。它的工作原理,但增加一个点击监听按钮可能会更有效。
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.
答
我发现,如果我使用一个AbsoluteLayout和按钮XML下方,它的工作原理:
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"
/>