yanzi1225627 yanzi1225627 - 1 year ago 132
Android Question

How to manually enable android hardware acceleration after setContentView?

In my SplashActivity, sometimes it will display a image view , and sometimes it will display gif. I use android-gif-drawable to play gif. But I found, if I don't set activity

<activity android:hardwareAccelerated="true" />
, gif will play under normal rate. Only I enable hardwareAccelerated, it plays normal. However, after I set
<activity android:hardwareAccelerated="true" />
, I use
adb shell dumpsys com.yanzi.demo
found, GL cost about 20M memory. So, I must use java to enable hardware accelerate, only when play gif.

I use next code to enable it:


write it before
works well. But, it takes time for me to check whether play gif or not, so it must be enabled after
. I test it, found don't work. Someone can help me? Or, this is a problem with no way? Api guides

Answer Source

If you enable hardware accelerated that way after setContentView, you must use WindowManager to add view. Otherwise´╝î it will not work at all. Hope to help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download