如何在 Android 上的视图顶部绘制/移动图像

发布于 2024-12-17 05:01:18 字数 443 浏览 2 评论 0原文

因此,我为游戏创建了默认视图

ScreenShot.. 现在我需要添加可以在视图顶部移动的卡片。

到目前为止,我只有一个类 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

ScreenShot..
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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘香 2024-12-24 05:01:18

当然,有很多方法可以实现这一点:

我认为最好的处理方法是使用 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 a SurfaceView to be precise), and deal with the onDraw 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文