Creo un Dialog a cui associo un layout che all’interno ha un imageView.
Questa è associata con il background a my_progress_indeterminate.xml che dovrebbe farmi partire un animazione di tre immagini.
Il problema è che nel dialog non parte l’animazione. Vedo fissa la prima immagine.
Il codice però funziona perché se metto la stessa imageView in un layout l’animazione parte correttamente.
È come se fosse bloccato il foreground nel Dialog.
Avete qualche idea per risolvere questa problematica?
Animation.xml
codice:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/custom_dialog_async" android:orientation="vertical"> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="CARICAMENTO IN CORSO, ATTENDERE PREGO..." android:textColor="@color/black" /> <ImageView android:background="@drawable/my_progress_indeterminate" android:layout_width="wrap_content" android:layout_height="43dip" android:layout_gravity="center_horizontal" android:layout_marginLeft="25dp" android:scaleType="fitCenter" android:id="@+id/image" /> </LinearLayout>
my_progress_indeterminate.xml
codice:<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" > <item android:drawable="@drawable/img1" android:duration="150"/> <item android:drawable="@drawable/ img2" android:duration="150"/> <item android:drawable="@drawable/ img3" android:duration="150" /> </animation-list>
Dialog custom
codice:public class LoadDialog extends Dialog{ private TextView message; ImageView image; AnimationDrawable animation; public LoadDialog(Context context) { super(context); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.custom_dialog_async); message = (TextView) findViewById(R.id.text); image = (ImageView) findViewById(R.id.image); image.setBackgroundResource(R.drawable.my_progress_indeterminate); animation = (AnimationDrawable) image.getBackground(); } public void setText(String msg) { message.setText(msg); } @Override public void show() { super.show(); animation.start(); } @Override public void dismiss() { animation.stop(); super.dismiss(); } }

LinkBack URL
About LinkBacks
Rispondi quotando