Android的:如何放置一个按钮一个x,在画布之上y位置 [英] Android: how to place a button at an x,y position over top of Canvas
本文介绍了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"
/>
这篇关于Android的:如何放置一个按钮一个x,在画布之上y位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文