venkat.103
Lurker
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" androidneshot="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 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" androidneshot="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