Read More

Using TextSwitcher and ImageSwitcher with simple animation

Sometimes, To make the app pages look more attractive we need to apply different animations to our mobile content and for this Android provides developers two classes namely TextSwitcher and ImageSwitcher in order to have a transition animation in an Android View. TextSwitcher is specially designed to contain only TextView as a child. It is used to animate any text on the app page. Whenever the setText(CharSequence) method is called, TextSwitcher animates the current text out and animates the new text in. TextView and TextSwitcher work in a similar way. Similarly, an ImageSwitcher replaces an ImageView. It also contains only ImageView as a child and animates the views in and out.

 

Let us see the steps to implemen TextSwitcher.

First we will define our XML file which will contain a TextSwitcher. Below is a sample.xml.

 

Now in our Activity class we will initialise this TextSwitcher.

As you can see in the above code segment first we have picked the view and the set a ViewFactory on the TextSwitcher. ViewFactory actually provide the view which will be loaded when the view is changed.Below is the example code for ViewFactory.

Now we are all set. Now whenever we call the setText function of the TextSwitcher it will change the text according to the animation applied.

That’s all !!! Just by following these simple steps you can also implement ImageSwitcher.

Thank you very much. This is Vedesh Kumar signing off.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close