Android display GIF image example code

Recently, a friend told me that I wanted to get her an alarm clock app... The function is actually very simple... Just get a simple alarm clock. Design the time yourself. Then when the time came, the sound of the alarm clock was the sound recorded by her boyfriend... So I started the whole process

When I did this for the first time, I wanted to make the home page interface into a GIF animation special effect. It looks cute... Suitable for girls, so I have the following effect picture

Upper code

Android. Graphics. Movie in Android is a very convenient tool provided by Android. First, rewrite the control view and customize a gifview movie that displays GIF graphs. In fact, it manages multiple frames in GIF animation. It can draw the corresponding frame image at the time of draw() only by settime(). Through the conversion relationship between the current time and duration, it is easy to realize the effect of GIF moving.

Secondly, define the view in the XML layout file. The code is as follows:

Finally, the code used in mainactivity is as follows:

Styles.xml

Raw is a file under res, which contains GIF animation

I put an animation and a music file here, because what I want to do is a sound alarm

The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>