As shown here , you can use image views to get a custom scroll effect.
The XML format for the custom execution string in this example:
<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:layout_height="wrap_content" android:paddingLeft="30sp" android:paddingRight="30sp"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/progress_1" android:id="@+id/imgOne" android:tag="1"></ImageView> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/progress_2" android:id="@+id/imgTwo" android:layout_toRightOf="@id/imgOne" android:tag="2"></ImageView> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/progress_3" android:id="@+id/imgThree" android:layout_toRightOf="@id/imgTwo" android:tag="3"></ImageView> <TextView android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_toRightOf="@id/imgThree" android:layout_width="wrap_content" android:layout_alignTop="@id/imgThree" android:layout_alignBottom="@id/imgThree" android:gravity="bottom" android:text="Please Wait..."></TextView> </RelativeLayout>
And then it creates a list of images in the class file as:
private void prepareLayout() { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.myprogressbar, null); addView(view); imageHolders = new ArrayList<ImageView>(); imageHolders.add((ImageView) view.findViewById(R.id.imgOne)); imageHolders.add((ImageView) view.findViewById(R.id.imgTwo)); imageHolders.add((ImageView) view.findViewById(R.id.imgThree));
Then it starts Thread, which sleeps for 0.3 seconds and calls the handler using handler.sendEmptyMessage(0); , and finally in Handler it does the rest of the image work:
@Override public void handleMessage(Message msg) { int currentImage = 0; int nextImage = 0; // Logic to change the images for (ImageView imageView : imageHolders) { currentImage = Integer.parseInt(imageView.getTag().toString()); if (currentImage < 9) { nextImage = currentImage + 1; } else { nextImage = 1; } imageView.setTag("" + nextImage); imageView.setImageResource(getResources().getIdentifier( images.get(nextImage - 1), "drawable", "com.beanie.example")); } super.handleMessage(msg); }
Also consider here and here .
Harry joy
source share