-6

I want scroll the list view continuously like Marquee effect, for that what I need to add for list view.

Sagar Pilkhwal
  • 3,998
  • 2
  • 25
  • 77

1 Answers1

-1

Refer to this post or you can use some adapter EndlessAdapter or this one.

MarqueeLayout.java

import android.content.Context;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;

public class MarqueeLayout extends FrameLayout {
    private Animation animation;
    public MarqueeLayout(Context context) {
        super(context);
        animation = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, +1f,
            Animation.RELATIVE_TO_SELF, -1f,
            Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f
        );
        animation.setRepeatCount(Animation.INFINITE);
        animation.setRepeatMode(Animation.RESTART);
    }
    public void setDuration(int durationMillis) {
        animation.setDuration(durationMillis);
    }   
    public void startAnimation() {
        startAnimation(animation);
    }
}

and MarqueeLayoutActivity.java

import android.app.Activity;
public class MarqueeLayoutActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /*List view code here*/
        MarqueeLayout marqueeLayout = new MarqueeLayout(this);
        marqueeLayout.setDuration(10000);
        marqueeLayout.addView(listView);
        marqueeLayout.startAnimation();
        setContentView(marqueeLayout);
    }
}

Hope it helps.

Kartik
  • 709
  • 1
  • 9
  • 21
Sagar Pilkhwal
  • 3,998
  • 2
  • 25
  • 77