首页 \ 问答 \ Android - 支持多屏幕画布问题(Android - Supporting multiple screens canvas issue)

Android - 支持多屏幕画布问题(Android - Supporting multiple screens canvas issue)

我使用这个教程做了一个测试游戏http://www.kilobolt.com/day-6-the-android-game-framework-part-ii.html现在我想在游戏商店做一个真正的游戏发布。

我希望我的游戏支持不同的屏幕尺寸。 因此,在阅读了很多内容后,我现在知道我必须为不同的屏幕尺寸指定不同的布局。 但我不知道如何处理本教程中的一些代码。

它基本上有这样的东西:

int frameBufferWidth = 800;
int frameBufferHeight = 480;
Bitmap frameBuffer = Bitmap.createBitmap(frameBufferWidth, frameBufferHeight, Config.RGB_565);

然后用于创建Canvas:

this.canvas = new Canvas(frameBuffer);
  • 我如何将其适应布局?
  • 那些尺寸是像素吗?
  • 我应该将它们传递给dp值吗?
  • 我应该在xml布局上指定那些宽度和高度值吗?

我认为正确的答案是将它们传递给代码上的dp,但即便如此,我也不知道该怎么做。

我在教程网站上问了同样的问题,但还没有得到任何回复,请帮忙。


I did a test game using this tutorial http://www.kilobolt.com/day-6-the-android-game-framework-part-ii.html and now I want to do a real game for publishing on the play store.

I want my game to support different screen sizes. So after reading a lot I now know that I have to specify different layouts for different screen sizes. But I don't know what to do about some code from the tutorial.

It basically has something like this:

int frameBufferWidth = 800;
int frameBufferHeight = 480;
Bitmap frameBuffer = Bitmap.createBitmap(frameBufferWidth, frameBufferHeight, Config.RGB_565);

which is then used to create the Canvas:

this.canvas = new Canvas(frameBuffer);
  • How do I adapt that into the layouts?
  • Are those sizes in pixels?
  • Should I pass them to dp values?
  • Should I specify those width and height values on the xml layouts?

I think the correct answer would be to pass them to dp on the code, but even so, I don't really know how to do it.

I asked the same question on the tutorial website but haven't got any response yet, please help.


原文:https://stackoverflow.com/questions/21102026
更新时间:2023-04-25 18:04

最满意答案

像这样从get()移除activity

Picasso.get().load(imageuri).networkPolicy(NetworkPolicy.OFFLINE).into(imageView, new Callback() 

这将解决您的问题。


Remove activity from get() like this.

Picasso.get().load(imageuri).networkPolicy(NetworkPolicy.OFFLINE).into(imageView, new Callback() 

This will fix your problem.

相关问答

更多