-2

I am using a Custom Dialog in my application.So for I have created a Custom Dialog class in which i have called an XML layout which contains a imageview.

Here is my CustomDialog class code...

enter image description here

    public class CustomDialog extends DialogFragment {

        public static CustomDialog newInstance() {
            return new CustomDialog();
        }


        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.dialog, container, false);
            Glide.with(this).load(R.drawable.loader1).placeholder(R.drawable.loader1)
                                   .into((ImageView) v.findViewById(R.id.progress));  //loader1 is a gif file
            getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
            getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

            if (getDialog() == null)
            super.setShowsDialog (false);
            return v;
            }

            }

And here is my xml file code

<?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:background="#00FFFFFF"
    android:orientation="vertical">

    <ImageView                           //image view containing the loader gif
        android:id="@+id/progress"
        android:layout_width="40dp"
        android:background="#00FFFFFF"
        android:layout_height="40dp" />

</LinearLayout>

I put my gif in all the drawable folders but still the gif loader gets blurred while rotating in any of the device size whether hdpi,mpdi,etc.. Suggest me the solution so that the loader does not gets blurred

Piyush
  • 18,895
  • 5
  • 32
  • 63
neha
  • 107
  • 2
  • 11

1 Answers1

0

You can change your Glide code to this to test

Glide.with(context).load(R.drawable.loading).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).crossFade().into(loadingImageView);

or using this library https://github.com/koral--/android-gif-drawable to load gifs

EDIT: If you use above library, change android:background="@drawable/bg_anim from xml to android:background="@android:color/transparent"

EDIT2: According to Glide owner, version 3.8.0-SNAPSHOT or later will solve the transparent function. Use this:

compile 'com.github.bumptech.glide:glide:3.8.0-SNAPSHOT'
Harry T.
  • 3,478
  • 2
  • 21
  • 41
  • this also shows the gif with white background .I want it to be transparent – neha Jan 16 '17 at 09:57
  • I used this line of code Glide.with(context).load(R.drawable.loading).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).crossFade().into(loadingImageView); – neha Jan 16 '17 at 10:06
  • @neha manual `loadingImageView` xml set background to transparent like above – Harry T. Jan 16 '17 at 10:10
  • This also doesnt work,,check my edited question..See the screenshot – neha Jan 16 '17 at 10:13