Animation on textviews placed inside a linear layout

421 views Asked by At

I need to implement an animation on text views which are placed inside the layout,

My requirement is, I need to show Ist three text views on the screen

"Title1(left of the screen)  Title2(center)   Title3(right of the screen)".

when user click on the text 'Title3' i need to show

 Title2(at left)   Title3(at center) and Title4(at right).

and then when we click on 'Title4' it will show

Title3(at left) Title4(at center) and Title1(at right) like a rotation. How can we implement this kind of animation,

This is my code,

in onclick() i have called below lines for scale animation,

tv3.setAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_to_left));
tv2.setAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_to_left));
tv1.setAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_to_left));
tv3.getAnimation().setAnimationListener(flipperAnimationListener);

and my animation listener is given below

flipperAnimationListener = new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }
            @Override
            public void onAnimationRepeat(Animation animation) {}
            @Override
            public void onAnimationEnd(Animation animation) {
                changeTab();
            }
        };
1

There are 1 answers

1
QArea On

Why didn't you use ViewPager? It contains what you want.

Here's an example: https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSFjdgbbZGqUzaWTmm7Rvj4OtRx2oWnHfBYghwwmRIoStKLnzfLAg

This is an example of ViewPager: http://developer.android.com/training/animation/screen-slide.html

To activate "PagerTitleStrip" just override getPageTitle:

@Override
public CharSequence getPageTitle(int position) {
return "Title " + position;
}