I want scroll the list view continuously like Marquee effect, for that what I need to add for list view.
Asked
Active
Viewed 327 times
-6
-
2be more clear with your question.. – Pragnesh Ghoda シ Sep 03 '14 at 11:12
-
I have one listview, I want that list view to be keep scrolling automatically @Prag's シ – Mahesh Yallure Sep 03 '14 at 11:50
-
Welcome to [so]. Questions here should __show research effort or attempts__. [What have you tried?](http://whathaveyoutried.com) Please take a __[tour]__. – Unihedron Sep 03 '14 at 12:17
1 Answers
-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
-
Thank u SagarP ur post is for state change of list by user, But i want the list to be keeps scrolling automatically, Just like marquee. – Mahesh Yallure Sep 03 '14 at 11:53
-
Does [this](http://stackoverflow.com/questions/12525760/how-to-add-marquee-effect-to-listview) answer your question – Sagar Pilkhwal Sep 03 '14 at 11:55
-
I had gonn through that post, but that is for single textview not for entire listview to be scrolling automatically. – Mahesh Yallure Sep 03 '14 at 12:04
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Qantas 94 Heavy Sep 03 '14 at 12:15
-
one way to do it may be by using some animations or you can run a thread which will use listview method called `smoothScrollToPosition()`and then set the position to first/last position – Sagar Pilkhwal Sep 03 '14 at 12:17
-
thanks, smoothScrollToPosition() is this a built in function in listview or what? – Mahesh Yallure Sep 03 '14 at 12:24
-
I'll try this above method and let u know SagarP, Thanks for help. – Mahesh Yallure Sep 03 '14 at 12:26
-
@Qantas 94 Heavy i have now posted some code. is it better now? vote-up if so. – Sagar Pilkhwal Sep 03 '14 at 12:29