1. Check out our companion app, Forums for Android! Download from Google Play

Horzental Image Scrolling dynamically

Discussion in 'Application Development' started by venkat.103, Nov 26, 2010.

  1. venkat.103

    venkat.103 New Member
    Thread Starter
    5

    Nov 23, 2010
    2
    0
    5
    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:eek:neshot="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
     

    Advertisement

  2. harish.grandhi@gmail.com

    25

    Nov 27, 2010
    4
    0
    25
    By using image switcher control it is very easy .. So try with that control
     
  3. venkat.103

    venkat.103 New Member
    Thread Starter
    5

    Nov 23, 2010
    2
    0
    5
    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.
     

Share This Page

Loading...