How to remove frame animation background (or set transparency)?
When I set the background color in the xml layout file to be transparent, black appears when it starts.
When I setBackgroundColor (0); in java code , I get the following exception
java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.graphics.drawable.AnimationDrawable
/res/layout/dialog_loading.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/background_black_semitransparent" > <FrameLayout android:layout_width="@dimen/dialog_width" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@android:color/transparent" > <ImageView android:id="@+id/iv_loading" android:layout_width="@dimen/dialog_width" android:layout_height="wrap_content" android:scaleType="fitCenter" android:adjustViewBounds="true" android:background="@android:color/transparent" /> </FrameLayout> </LinearLayout>
/res/anim/frame_animation.xml
<?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/loading_1_00000" android:duration="75" /> <item android:drawable="@drawable/loading_1_00002" android:duration="75" /> <item android:drawable="@drawable/loading_1_00004" android:duration="75" /> <item android:drawable="@drawable/loading_1_00006" android:duration="75" /> <item android:drawable="@drawable/loading_1_00008" android:duration="75" /> <item android:drawable="@drawable/loading_1_00010" android:duration="75" /> <item android:drawable="@drawable/loading_1_00012" android:duration="75" /> <item android:drawable="@drawable/loading_1_00014" android:duration="75" /> <item android:drawable="@drawable/loading_1_00016" android:duration="75" /> <item android:drawable="@drawable/loading_1_00018" android:duration="75" /> <item android:drawable="@drawable/loading_1_00020" android:duration="75" /> <item android:drawable="@drawable/loading_1_00022" android:duration="75" /> <item android:drawable="@drawable/loading_1_00024" android:duration="75" /> <item android:drawable="@drawable/loading_1_00026" android:duration="75" /> <item android:drawable="@drawable/loading_1_00028" android:duration="75" /> <item android:drawable="@drawable/loading_1_00030" android:duration="75" /> <item android:drawable="@drawable/loading_1_00032" android:duration="75" /> <item android:drawable="@drawable/loading_1_00034" android:duration="75" /> <item android:drawable="@drawable/loading_1_00036" android:duration="75" /> <item android:drawable="@drawable/loading_1_00038" android:duration="75" /> <item android:drawable="@drawable/loading_1_00040" android:duration="75" /> <item android:drawable="@drawable/loading_1_00042" android:duration="75" /> <item android:drawable="@drawable/loading_1_00044" android:duration="75" /> <item android:drawable="@drawable/loading_1_00046" android:duration="75" /> <item android:drawable="@drawable/loading_1_00048" android:duration="75" /> <item android:drawable="@drawable/loading_1_00050" android:duration="75" /> <item android:drawable="@drawable/loading_1_00052" android:duration="75" /> </animation-list>
Java Code:
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Error:
06-07 12:04:39.450: E/AndroidRuntime(6581): FATAL EXCEPTION: Timer-1 06-07 12:04:39.450: E/AndroidRuntime(6581): java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.graphics.drawable.AnimationDrawable 06-07 12:04:39.450: E/AndroidRuntime(6581): at za.co.domain.client.product.tools.ProgressDialogFragment$AnimationLoop.run(ProgressDialogFragment.java:79) 06-07 12:04:39.450: E/AndroidRuntime(6581): at java.util.Timer$TimerImpl.run(Timer.java:284)
EDIT:
See screenshot
from the moment that android is offered: background = "# 0000":
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#0000" > <FrameLayout android:layout_width="@dimen/dialog_width" android:layout_height="wrap_content" android:layout_gravity="center" android:background="#0000" > <ImageView android:id="@+id/iv_loading" android:layout_width="@dimen/dialog_width" android:layout_height="wrap_content" android:scaleType="fitCenter" android:adjustViewBounds="true" android:background="#0000" /> </FrameLayout> </LinearLayout>
source share