0

I am working on my school Project of Music Player. I am able to fetch the songs list from External drive and able to display the same in listView under Fragment. When I click on the song, it plays and snackbar is opened.

I want this Snackbar to display 'gif image' with animation.I have tried several online code but could not get to any solution

Below is my code:

Snackbar snackbar = Snackbar.make(relativeLayout, nameOfSong , Snackbar.LENGTH_INDEFINITE);
View snackbarLayout = snackbar.getView();
TextView textView = (TextView)snackbarLayout.findViewById(android.support.design.R.id.snackbar_text);
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.musicbars, 0, 0, 0); 
textView.setCompoundDrawablePadding(getResources().getDimensionPixelOffset(R.dimen.my_value));
snackbar.show();

I want to add Gif of Music Bars which should keep on animating till the song lasts.

Thanks

Molly
  • 1,887
  • 3
  • 17
  • 34
  • 1
    `CompoundDrawables` does not supports `GIF` images . You need to use Custom View with `GIF View`. Follow [Set Custom Layout in snack Bar](https://stackoverflow.com/questions/32453946/how-to-customize-snackbars-layout) – ADM Feb 05 '19 at 03:41

1 Answers1

0

Custom SnackBar in Android

Try this for create Custom Snackbar layout and load gif image in ImageView, I hope this helps you and visit a link to load gif in ImageViewLoad gif in ImageView

Snackbar snackbar = Snackbar.make(parentLayout, "", Snackbar.LENGTH_LONG);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) 
snackbar.getView();
TextView textView = (TextView) 
layout.findViewById(android.support.design.R.id.snackbarText);
textView.setVisibility(View.INVISIBLE);

View snackView = mInflater.inflate(R.layout.snckBar, null);
ImageView imageView = (ImageView) snackView.findViewById(R.id.image);
imageView.setImageBitmap(image);
TextView textViewTop = (TextView) snackView.findViewById(R.id.text);
textViewTop.setText(text);
textViewTop.setTextColor(Color.WHITE);
layout.setPadding(0,0,0,0);
layout.addView(snackView,0);
snackbar.show();