Barra de progreso personalizada en Android?

No tengo una idea de cómo hacer esto. Mi barra de progreso debe ser la forma de la nube. ¿Puede alguien dirigirme a un libro, tutorial o simplemente dar el método correcto paso a paso?

Gracias por tu tiempo.

Como se muestra aquí , puede utilizar vistas de imagen para obtener la barra de desplazamiento personalizada como efecto.

El XML de presentación para la barra de progreso personalizada en ese ejemplo es:

<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> 

Y luego crea una lista de imágenes en el archivo de clase como:

 /** * Loads the layout and sets the initial set of images */ 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)); // Prepare an array list of images to be animated images = new ArrayList<String>(); images.add("progress_1"); images.add("progress_2"); images.add("progress_3"); images.add("progress_4"); images.add("progress_5"); images.add("progress_6"); images.add("progress_7"); images.add("progress_8"); images.add("progress_9"); } 

A continuación, inicia un Thread que duerme durante 0,3 segundos y llama al manejador con handler.sendEmptyMessage(0); Y finalmente en Handler hace el resto del trabajo de las imágenes:

 @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); } 

También eche un vistazo aquí y aquí .

Terminé usando la Barra de Progreso Personalizada con Esquinas Redondas como una base para la mina que Harry Joy recomendó. Sin embargo, si quieres la misma funcionalidad que la versión de SDK de Android, que tiene intermedio de la clase ProgressBar tuve que hacer algunos cambios. Los cambios que he hecho permiten que se pueda definir y animar un dibujo intermedio.

Asegúrese de seguir las instrucciones aquí , pero reemplace la clase RoundProgress con esto:

 public class RoundProgress extends RelativeLayout { private ImageView progressDrawableImageView; private ImageView trackDrawableImageView; private ImageView backGroundImageView; private double max = 100; private AttributeSet attrs2 ; private Transformation mTransformation; private AlphaAnimation mAnimation; private int mBehavior; private int mDuration; private Interpolator mInterpolator; private static Context ctx; private int bgResource; public int getMax() { Double d = new Double(max); return d.intValue(); } public double getMaxDouble() { return max; } public void setMax(int max) { Integer maxInt = new Integer(max); maxInt.doubleValue(); this.max = max; } public void setMax(double max) { this.max = max; } public RoundProgress(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.round_progress, this); setup(context, attrs); } protected void setup(Context context, AttributeSet attrs) { attrs2 = attrs; ctx = context; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundProgress); //setBackgroundResource(R.drawable.custom_loading_bg); backGroundImageView = (ImageView) findViewById(R.id.background_image_view); backGroundImageView.setBackgroundResource(R.drawable.custom_loading_bg); final String xmlns="http://schemas.android.com/apk/res/com.digiphd.prospec"; bgResource = attrs.getAttributeResourceValue(xmlns, "progressDrawable", 0); progressDrawableImageView = (ImageView) findViewById( R.id.progress_drawable_image_view); progressDrawableImageView.setBackgroundResource(bgResource); int trackResource = attrs.getAttributeResourceValue(xmlns, "track", 0); trackDrawableImageView = (ImageView) findViewById(R.id.track_image_view); trackDrawableImageView.setBackgroundResource(trackResource); int progress = attrs.getAttributeIntValue(xmlns, "progress", 0); setProgress(progress); int max = attrs.getAttributeIntValue(xmlns, "max", 100); setMax(max); int numTicks = attrs.getAttributeIntValue(xmlns, "numTicks", 0); a.recycle(); ProgressBarOutline outline = new ProgressBarOutline(context); //addView(outline); } public void setProgress(Integer value) { setProgress((double) value); } public void setProgress(double value) { ClipDrawable drawable = (ClipDrawable) progressDrawableImageView.getBackground(); double percent = (double) value/ (double)max; int level = (int)Math.floor(percent*10000); drawable.setLevel(level); } public void setIntermediate(boolean t) { if(t){ progressDrawableImageView.setBackgroundResource(R.drawable.custom_intermediate_bg); startAnimation(); }else{ progressDrawableImageView.clearAnimation(); progressDrawableImageView.setBackgroundResource(bgResource); } } /** * <p>Start the indeterminate progress animation.</p> */ void startAnimation() { int visibility = getVisibility(); if (visibility != VISIBLE) { return; } Log.d("INTERMEDIATE","ANIMATION START!"); mDuration = 1000; if (mInterpolator == null) { mInterpolator = new LinearInterpolator(); } mTransformation = new Transformation(); mAnimation = new AlphaAnimation(0.0f, 1.0f); mAnimation.setRepeatMode(Animation.REVERSE); mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setDuration(mDuration); mAnimation.setInterpolator(mInterpolator); mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME); progressDrawableImageView.startAnimation(mAnimation); } } 

Ahora en su actividad, puede llamar a .setIntermediate (true o false) cuando sea necesario.

  • Cómo poner dos EditText en la misma línea
  • Cómo dibujar un círculo dentro de un círculo con formas de Android xml?
  • AutoCompleteTextView con lista personalizada: cómo configurar OnItemClickListener
  • Vinculación de datos de Android en vistas individuales agregadas a LinearLayout mediante programación?
  • ¿Cómo pasar una ruta de acceso de archivo que está en la carpeta assets a File (String path)?
  • ¿Cómo ocultar por programación algunos elementos de la vista, pero no todos, en una salida XML?
  • Quiero usar Xpath en Android para analizar XML
  • Solución automática de laberinto
  • ¿Cómo puedo editar las dimensiones de un elemento de menú PopUp en Android?
  • ¿Cómo poner el carácter del espacio en un nombre de la secuencia en XML?
  • Fondo de menú Android negro con Theme.AppCompat?
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.