开发者

Android animated GIF

开发者 https://www.devze.com 2023-04-11 19:06 出处:网络
I\'m trying to display animated GIF using WebView. It works fine on most devices, but still some of them doesn\'t support animations and a static GIF is displayed.

I'm trying to display animated GIF using WebView. It works fine on most devices, but still some of them doesn't support animations and a static GIF is displayed.

How can I detect if the device supports animated GIFs in WebView, so I can displ开发者_运维百科ay appropriate message if it doesn't?


Yeah, this seams to be a common issue. There are some workarounds posted in the Bug-report, but it seams that it's not an Android Core-feature.

Some company's (like HTC) maybe took care of this themselves, but you can't rely on animated gif's to work.


As you can see with this link http://code.google.com/p/android/issues/detail?id=3422. this issue still unresolved for two yrs. But the most of the devices work fine in Gingerbread. So you might check the OS level (starting in level 9) which is works or not


Hate to say it this way, but its the most effective way to find out. Open a GIF image, and if it doesnt play... Its not supported on the device


Animated GIF support was added to Android in version 2.2. If you check the version using Build.VERSION, it should tell you whether the GIFs are working.


In the Android C++ file external/webkit/WebCore/platform/graphics/android/ImageSourceAndroid.cpp there is a function static bool should_use_animated_gif(int width, int height) which returns true if ANDROID_LARGE_MEMORY_DEVICE is defined.

Here, Leon Scroggins (seems to be a Google engineer) says that ANDROID_LARGE_MEMORY_DEVICE is defined "for all arm devices with a VFP, and all non-arm devices."

Edit: This is confirmed by external/webkit/Android.mk:

ifeq ($(ARCH_ARM_HAVE_VFP),true)
LOCAL_CFLAGS += -DANDROID_LARGE_MEMORY_DEVICE
endif

In my understanding, all ArmV7 cpus do have a VFP, so animated GIFs should work on modern cpus with ArmV7.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号