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
最满意答案
像这样从
get()
移除activity
。Picasso.get().load(imageuri).networkPolicy(NetworkPolicy.OFFLINE).into(imageView, new Callback()
这将解决您的问题。
Remove
activity
fromget()
like this.Picasso.get().load(imageuri).networkPolicy(NetworkPolicy.OFFLINE).into(imageView, new Callback()
This will fix your problem.
相关问答
更多-
毕加索的内存不足(Out of memory Error in picasso)[2023-11-10]
类似的问题。 Android Picasso ImageView - 内存异常MemoryLeak 当Android“展开”您的图像(即将其解码为位图)时,它将使用每像素4个字节。 计算像素数,将其乘以4再乘以20(图像数量),您可能会接近100mb的数字。 例如,如果您的图像具有1,000,000像素分辨率,那么它将是1,000,000 x 4 x 20 = 80mb。 使用某种LRU缓存或类似(或者使用Universal Image Loader库来处理缓存)并且只在需要时加载位图。 Similar q ... -
清除错误的数据上下文?(Clearing data context on error?)[2023-04-13]
我想到了。 基本上,我所要做的就是使用上下文的DeleteOnSubmit()方法从数据上下文中删除有问题的数据。 我所要做的就是在我想要删除的上下文中提供哪个数据对象: dataContext.DeleteOnSubmit(offendingData); I figured it out. Basically, all I had to do was remove the offending data from the data context by using the DeleteOnSubmit() ... -
Android Glide上下文错误(Android Glide Context Error)[2022-04-25]
不,Glide不会为每个Activity或Fragment维护单独的缓存。 您获得缓存未命中的原因可能是因为您在Fragment中使用的View您在“ Activity使用的View宽度和高度不完全相同。 您可以使用DiskCacheStrategy.SOURCE (仅对远程图像有意义),或者您可以在两个地方使用override()使用固定大小。 No, Glide doesn't maintain separate caches per Activity or Fragment. The reason y ... -
毕加索错误加载图片?(Picasso error loading image?)[2022-07-19]
这里的错误是你以错误的方式使用库。 "这里无效。 您还使用了.into(imageView)和resize(..)两次。 尝试这个。 Picasso.with(context).load("http://egyptianstreets.com/wp-content/uploads/2016/08/egyptischemoefti.jpg").resize(60,60).centerCrop(). into(imageView); Here error is you are usi ... -
毕加索上下文错误(Picasso context error)[2022-04-25]
像这样从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 C ... -
创建一个接口类,如: public interface OnItemClickListener { void onItemClick(String item); } 并在ImageListFragment中实现这个类。 public class ImageListFragment extends Fragment implements OnItemClickListener { 现在当您在ImageListFragment中创建适配器对象时,请更改您的代码 imageRecyclerViewad ...
-
为什么在Picasso.with(上下文)中,毕加索要求上下文?(Why in Picasso.with(context), Picasso asks for context?)[2023-02-22]
你已经发布了你的答案 - public Builder(Context context) { if (context == null) { throw new IllegalArgumentException("Context must not be null."); } this.context = context.getApplicationContext(); } 毕加索是一个图书馆,而不是一个应用程序。 在创建Picasso实例时,如果你不传递context ,那么你认为它将如 ... -
Android毕加索,错误原因(Android picasso, error reason)[2022-02-13]
我有同样的问题,我解决了它: 全局实例侦听器接收HTTP异常,以报告崩溃报告服务或分析服务的上游。 问候: https : //github.com/square/picasso/issues/379 public class MyClass implements Picasso.Listener { @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) { // ... -
以下是一些代码,基本上显示了如何执行此操作。 它不使用igraph对象或doclist的函数,因此您必须自己调整它以使用它们。 首先,这里有两个引发错误的函数: g <- function(y) { stop("g failed") } h <- function(y) { stop("h failed") } 以下是您的功能的清理版本,使用doclist一些不同功能: func <- function(x, remove=NULL) { if (!is(x, "numeric ...
-
您的问题是,现在您的配置没有被.net解释为因为您更改了其名称。 如果你想在外部文件中声明你的对象,你应该这样做 在App.config中:
相关文章
更多- HTML5 Canvas 图像动画的实现
- 想买android手机练开发,谁推荐款型号吧
- Android学习之 UI效果
- 疯狂Android讲义
- HTML5-canvas画布坐标体系_HTML5网页游戏坦克大战04
- HTML5画布(Canvas)【HTML5教程 - 第七篇】
- Android开发权威指南.pdf 电子书下载
- android 集成所有分享平台
- android布局问题
- HTML5 Canvas 画图标签、画线、圆、渐变色
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)