如何在 Android 上的视图顶部绘制/移动图像
因此,我为游戏创建了默认视图
现在我需要添加可以在视图顶部移动的卡片。
到目前为止,我只有一个类 HelloAndroidActivity.java
,其代码如下:
public class HelloAndroidActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
那么,我如何才能将其他图像引入到此现有视图中并操作它们呢?
So, I've made a default view for a game
and now I need to add cards that can be moved around on top of the view.
I have only one class so far, HelloAndroidActivity.java
with the following code:
public class HelloAndroidActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
So, how can I go about bringing other images onto this existing view, and manipulating them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,有很多方法可以实现这一点:
我认为最好的处理方法是使用 SurfaceView(或者,准确地说,扩展 SurfaceView) ,并处理
onDraw
事件并直接从存储的位图打印卡片。喜欢这种教程:
http://www.droidnova.com/playing -with-graphics-in-android-part-ii,160.html
我认为创建大量 Android 控件对于纸牌游戏来说并不是一个好主意。
Of course, there are many ways to realise that:
I suppose the best way to deal with, would be to use a
SurfaceView
(or, extending aSurfaceView
to be precise), and deal with theonDraw
event and print card directly from stored bitmaps.Like this kind of tutorial :
http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html
I don't think creating plenty of Android controls is a good idea for card games.