Anyone familiar with the emulator will know that during the loading phase the 'screen' of the AVD shows the word 'android' as in the image below...

enter image description here

The highlight (on the letters DRO in the image) 'scans' from left to right to act as an indeterminate progress indicator.

I don't do much graphics work so I'm not familiar with different animation techniques. Is that type of animation a common one and if so, what is it's name?

I'd like to implement something similar in my main activity's title bar. When opened, it would do a single highlight 'scan' of the activity name. No real purpose other than to add a bit of 'glitz' to the UX.

有帮助吗?

解决方案

That is most likely a bitmap animation (sprite animation) or two images where one is the effect layer put on top.

A sprite animation is simply put a prerendered imageset where the frames are just switched at a specified rate.

The other alternative is a partly transparent mask that is animated over the background image from left to right.

To illustrate the second point:

  1. First you have the background image:

background

  1. Then you have the mask. Note that white and transparent on white doesn't show that well. Here's a link to the image as well: http://i.imgur.com/bOcD4.png

mask

  1. When combined with an offset of the mask you get something like

combined

So you simply draw the mask over the background image and alpha blending will take care of the rest. The simplest way is probably to animate an imageview from a position that is 0-mask.width to a position that is background.width+mask.width.

If you want the mask to be more dynamic you will probably want to generate and render it for example in a custom view where you draw in onDraw to a canvas. You could make the effect a bit cooler if you combine it with a rotation using an AnimationSet (or Animator depending on Android target).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top