Android Animations similar to make marquee vertical

感情迁移 提交于 2019-12-02 14:49:40

问题


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?


回答1:


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();
}


来源:https://stackoverflow.com/questions/25731123/android-animations-similar-to-make-marquee-vertical

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!