Search code examples
androidandroid-layoutandroid-animationtextviewmarquee

Android Animations similar to make marquee vertical


Apologies for this basic question, as I'm a complete novice to Android:

I can make my TextView scroll horizontally on one line.

But what I need is multiple TextViews, which in a marquee fashion all scroll vertically to the bottom of the screen and then back up to the top.

I've been searching for hours and cannot see anything in the android API that seems to do this.

Or is there an animation feature that can accomplish this?


Solution

  • refer this GitHub Project it has a wonderful example in it too.

    Edit: make your xml some thing like this:

    <com.package.project.VerticalMarqueeTextView
    android:id="@+id/vmTextView"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/vmtvText"
    android:minLines="1"
    android:maxLines="10"
    android:width="250dp"
    android:textColor="@android:color/white"
    android:textStyle="bold" />
    

    In your activity class:

    private VerticalMarqueeTextView _txtView1; //declare a member variable
    

    In onCreate():

    _txtView1 = (VerticalMarqueeTextView) findViewById(R.id.mTextView1);
    _txtView1.setMovementMethod(new ScrollingMovementMethod());
    

    And in other activity lifecycle methods:

    @Override
    protected void onResume() {
    
        // Start or restart the Marquee if paused.
        if (_txtView1.isPaused()) {
            _txtView1.resumeMarquee();
        }
        super.onResume();
    }
    
    @Override
    protected void onPause() {
    
        // Pause the Marquee when the Activity pauses.
        _txtView1.pauseMarquee();
        super.onPause();
    }
    
    @Override
    protected void onDestroy() {
    
        _txtView1.stopMarquee();
        super.onDestroy();
    }