- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试用一系列启动动画 .png 制作一个简单的动态壁纸...
我正在使用
private static final int NUM_RES = 9;
private final Bitmap[] mPics = new Bitmap[NUM_RES];
CubeEngine() {
Resources res = getResources();
for (int i = 0; i< NUM_RES; i++) {
int id = res.getIdentifier("boot_0010" + (i + 1), "drawable", "minghai.wallpaper");
mPics[i] = BitmapFactory.decodeResource(res, id);
}
}
9 似乎是我能达到的最高值。如果我将 NUM_RES 设置为超过 9 的值,我会强制关闭。
我的所有文件都带有标签...boot_00101.pngboot_00102.pngboot_00103.pngboot_00104.pngboot_00105.pngboot_00106.pngboot_00107.pngboot_00108.pngboot_00109.pngboot_00110.pngboot_00111.pngboot_00112.pngboot_00113.pngboot_00114.png等等...我有大约 50 张图像正在尝试使用
有人知道我应该做什么吗?
日志:
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): FATAL EXCEPTION: main
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): java.lang.NullPointerException
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at android.graphics.Canvas.drawBitmap(Canvas.java:1115)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at minghai.wallpaper.YayoiWallpaper$CubeEngine.drawYayoi(YayoiWallpaper.java:166)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at minghai.wallpaper.YayoiWallpaper$CubeEngine.drawFrame(YayoiWallpaper.java:144)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at minghai.wallpaper.YayoiWallpaper$CubeEngine.onOffsetsChanged(YayoiWallpaper.java:117)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at android.service.wallpaper.WallpaperService$Engine.doOffsetsChanged(WallpaperService.java:669)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:847)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at android.os.Handler.dispatchMessage(Handler.java:99)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at android.os.Looper.loop(Looper.java:123)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at java.lang.reflect.Method.invokeNative(Native Method)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at java.lang.reflect.Method.invoke(Method.java:521)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-21 19:18:43.108: ERROR/AndroidRuntime(6475): at dalvik.system.NativeStart.main(Native Method)
@Yok非常感谢你成功了......在某种程度上,我似乎无法超过 30 我遇到了内存错误。很抱歉问,但是您是否知道一种更有效的方法来简单地获得像我想要实现的动画。
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): FATAL EXCEPTION: main
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.Bitmap.nativeCreate(Native Method)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:346)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:372)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at minghai.wallpaper.YayoiWallpaper$CubeEngine.<init>(YayoiWallpaper.java:60)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at minghai.wallpaper.YayoiWallpaper.onCreateEngine(YayoiWallpaper.java:35)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:814)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.os.Looper.loop(Looper.java:123)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at java.lang.reflect.Method.invoke(Method.java:521)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-22 04:35:03.720: ERROR/AndroidRuntime(8783): at dalvik.system.NativeStart.main(Native Method)
最佳答案
您的 for 循环更改存在问题:
“boot_0010”+ (i + 1)
到 “boot_00”+ (100+ (i + 1))
更改后的循环应如下所示:
for (int i = 0; i< NUM_RES; i++) {
int id = res.getIdentifier("boot_00" + (100 + (i + 1)), "drawable", "minghai.wallpaper");
mPics[i] = BitmapFactory.decodeResource(res, id);
}
循环的问题在于,之前它用于获取第 10 个图像的 boot_001010 而不是 boot_00110。这也是空指针异常的原因,因为 boot_001010 的图像不存在。
关于java - 添加超过10帧时动态壁纸动画强行关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3539406/
我发现这个插件可以让youtube视频作为背景:http://formstone.it/components/wallpaper 看起来很简单,但行不通。我也没有收到任何错误。我在 codepen 上
我为 android 制作壁纸,我希望用户可以选择选项。显示带有选项的菜单,但有问题。当我单击任何选项并返回壁纸屏幕时,它们不会更新新选项。为什么?我的代码WallpaperService: publ
你好 friend ,whatsapp 中有一个选项,我们可以通过它更改 whatsapp 聊天的背景墙纸。我正在制作一个项目,其中我提供了很多壁纸,我想从我的壁纸列表中设置壁纸 我使用了这段代码,但
我在几个地方读到桌面墙纸可以设置为 HTML 文档。有没有人成功地以编程方式改变它? 下面的 VB6 代码片段帮助我为 BMP 设置东西,但是当我尝试将它用于 HTML 时,我得到一个漂亮的蓝色背景,
我正在尝试使用 clx 更改墙纸,但它不起作用。我的代码有什么问题? (ql:quickload :clx) (defpackage #:wm/uw (:use #:cl #:xlib)) (in
我正在尝试指定一个 jpg 文件作为特定桌面的壁纸,但它似乎不起作用...而是将背景更改为另一个图像不同的文件夹...有人知道如何修复它吗? tell application "System Even
我正在尝试指定一个 jpg 文件作为特定桌面的壁纸,但它似乎不起作用...而是将背景更改为另一个图像不同的文件夹...有人知道如何修复它吗? tell application "System Even
我正在尝试使用代码更改 Android 壁纸。我正在使用 WallpaperManager 类,但没有成功。我在/drawable 目录中使用了一个 .png 图像。我收到一条错误消息,指出“原始类型
我想知道 Android Live 3D 壁纸是如何创建的?使用什么软件?以及开发人员如何使它与触摸、滑动等交互...我希望有人能帮助我如何开始...谢谢 最佳答案 3d 壁纸是在 opengles
我想知道是否可以使用我的笔记本电脑从 ADB 更改 android 壁纸。我不知道是否存在任何命令,或者我是否需要将图片复制到文件夹或编辑文本文件。如果可能的话,我需要通过 ADB 解决这个问题。 谢
我在过去的几周里(认真地)在网上搜索过,但我找不到我需要的东西。我只想启动一个与 set as 操作相对应的 Intent 。它通常提供设置为墙纸 或设置为联系人图片。然后,如果设备上安装了更多应用程
我想更改 Windows 中的桌面墙纸(7,如果有影响的话)。 我下面的尝试没有成功。据我所知,它不会更改墙纸、注册表项或执行除打印“0”以外的任何操作。 require 'Win32API' SPI
目标是在没有控件的情况下在 UIView 中播放视频文件 (*.mp4)。 它将作为 ViewController 和其他控件的背景/墙纸,即 tableview、文本字段、图像将在视频播放时显示在
有没有办法在 C++ 中获取 Windows 墙纸(图标后面)的句柄以便在上面绘制?这将允许制作事件桌面(在 Windows XP 之后停产)等价物、Wallpaper Engine 等价物或任何其他
我希望使用 Windows API 在 C++ 中更改 Windows 桌面背景墙纸。 我已阅读以下有关此主题的帖子: How to change desktop background using V
我知道这个问题之前已经被问过,但是有谁知道是否可以以编程方式为最新的 iphone 操作系统iOS4.2(测试版)设置主屏幕(壁纸)的背景图像 。我知道这在以前是不可能的。 我发现您可以通过写入/va
我是一名优秀的程序员,十分优秀!