[英]Is it possible to set an animated gif file as live wallpaper in android?
[英]Using .gif file in android live wallpaper
我的問題是關於這個職位
這篇文章中給出的方法似乎不起作用。 當我將動畫的.gif文件放在/ res / raw文件夾中時,出現錯誤,表明我的文件無法解析或不是字段。 關於原始文件夾中的資源,我應該了解些什么嗎,或者還有其他問題。 以下是代碼。
BelleEngine()引發IOException {
InputStream is = getResources().openRawResource(R.raw.ballerina);
if (is != null) {
try {
mBelle = Movie.decodeStream(is);
mBelleDuration = mBelle.duration();
} finally {
is.close();
}
} else {
throw new IOException("Unable to open R.raw.belle");
}
我在這里先向您的幫助表示感謝!
我已經嘗試了適用於我的示例。 我也嘗試過使用不同的.gif圖像,似乎它們沒有任何問題。 我的代碼是。 {
/**
* Method to init suitable wallpaper according to time.
*/
private void initWallpaperAccordingtoTime(InputStream inputStream) {
if (inputStream != null) {
try {
wallpaperGifStream = Movie.decodeStream(inputStream);
if (wallpaperGifStream != null) {
duration = wallpaperGifStream.duration();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
對該方法的調用如下。
initWallpaperAccordingtoTime(getResources().openRawResource(
R.raw.android_apple));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.