Horzental Image Scrolling dynamically


Last Updated:

  1. venkat.103

    venkat.103 New Member This Topic's Starter

    Joined:
    Nov 23, 2010
    Messages:
    2
    Likes Received:
    0
    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

    harish.grandhi@gmail.com New Member

    Joined:
    Nov 27, 2010
    Messages:
    4
    Likes Received:
    0
    By using image switcher control it is very easy .. So try with that control
     
  3. venkat.103

    venkat.103 New Member This Topic's Starter

    Joined:
    Nov 23, 2010
    Messages:
    2
    Likes Received:
    0
    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...