• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Horzental Image Scrolling dynamically

Hi Everyone,

I am new android platform, now i am working with small application. here there is requirement like multiple image scrolling dynamically. But unfortunately i am unable to scroll multiple images. But i am able to scroll single image. below i giving my code

res/drawable/scroll_images.xml

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" id="selected" android:oneshot="false">
<item android:drawable="@drawable/a1_5_1_2" android:duration="50" />
<item android:drawable="@drawable/a1_5_1_3" android:duration="50" />
<item android:drawable="@drawable/a1_5_1_4" android:duration="50" />
<item android:drawable="@drawable/a1_5_1_5" android:duration="50" />
<item android:drawable="@drawable/a1_5_1_6" android:duration="50" />
</animation-list>

ScrollImages.java
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}

private class SampleView extends View
{
int number =0;
int viewCount=0;
private AnimateDrawable mDrawable;
public SampleView(Context context)
{
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
//setBackgroundDrawable(context.getResources().getDrawable(R.drawable.lightwoodbkg));

Drawable dr1 = context.getResources().getDrawable(R.drawable.btn_add_item);
//dr1 = context.getResources().getDrawable(R.drawable.a1_5_1_3);

dr1.setBounds(0, 0, dr1.getIntrinsicWidth(), dr1.getIntrinsicHeight());


Animation an = new TranslateAnimation(-dr1.getIntrinsicWidth(),1024,90,0);

an.setDuration(10000);
an.setRepeatCount(-1);
an.initialize(0,0,0,0);
Log.d("home.java","---------->1 ");
mDrawable = new AnimateDrawable(dr1, an);
an.startNow();
}

@Override protected void onDraw(Canvas canvas) {
Log.d("home.java","---------->2 ");
System.out.println("Number is :"+number);
mDrawable.draw(canvas);
invalidate();
}
}
by using the above code i am able to scroll single image, Some body can help me to scroll multiple images.

Thanks
 
I worked around the image switcher controls, i am unable to write auto scrolling for multiple images, but i am able to scroll the images by dragging with mouse.

if any one have sample code, do me favor.
 
Back
Top Bottom