Search code examples
androidprogressdialogandroid-custom-view

Weird behavior with custom indeterminate progress view - ProgressDialog


I'm trying to make a custom progress bar with custom indeterminate view using animation_list with multiple images .. i've got it to work but it does something weird a part of the image is repeated like so ..enter image description hereenter image description here

Here is the code:

Dialog dialog = new Dialog(getActivity(), R.style.CustomProgressDialog);
    View customView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.custom_loader_layout, null, false);
    dialog.setContentView(customView);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);

Here is the layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical" >

<ProgressBar
    android:id="@+id/imgProgreso"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="5dip"
    android:background="@android:color/transparent"
    android:indeterminateDrawable="@drawable/loader_drawable" />

<TextView
    android:id="@+id/txtmensajedialogprogress"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|center_vertical"
    android:background="@android:color/transparent"
    android:gravity="center_vertical|center_horizontal"
    android:text="Wait ..."
    android:textColor="@android:color/black"
    android:textSize="15dp"
    android:textStyle="normal" />

and here is the custom style

<style name="CustomProgressDialog" parent="@android:Theme.Dialog" >
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:background">@android:color/transparent</item>
</style>

NOTE: worth mentioning this problem seems to happen when i use the custom style to make background transparent

Any help would be really appreciated :)


Solution

  • The answer was using an ImageView instead of a a custom layout resource while setting a background for the animation-list for some reason drawing that background for the animation-list got messed up.

    It simply goes something like that ..

    Dialog dialog = new Dialog(getActivity(), R.style.CustomProgressDialog);
        ImageView customView = new ImageView(getActivity());
        customView.setBackgroundResource(R.drawable.bg_loader);
        customView.setImageDrawable(getResources().getDrawable(R.drawable.custom_loader));
    

    while R.drawable.custom_loader is the animation-list