Snackbar 中的 Gif 图像
Gif Image in Snackbar
我正在研究我学校的音乐播放器项目。我能够从外部驱动器获取歌曲列表,并能够在 Fragment
下的 listView
中显示相同的内容。当我单击歌曲时,它会播放并打开 snackbar
。
我想让这个 Snackbar
显示 'gif image' 和 animation.I 已经尝试了几个在线代码但无法找到任何解决方案
下面是我的代码:
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();
我想添加 Music Bars 的 Gif,它应该一直动画直到歌曲结束。
谢谢
Android
中的自定义 SnackBar
尝试创建自定义 Snackbar 布局并在 ImageView
中加载 gif 图像,希望这对您有所帮助并访问 link 以在 ImageView
Load gif in ImageView 中加载 gif
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();
我正在研究我学校的音乐播放器项目。我能够从外部驱动器获取歌曲列表,并能够在 Fragment
下的 listView
中显示相同的内容。当我单击歌曲时,它会播放并打开 snackbar
。
我想让这个 Snackbar
显示 'gif image' 和 animation.I 已经尝试了几个在线代码但无法找到任何解决方案
下面是我的代码:
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();
我想添加 Music Bars 的 Gif,它应该一直动画直到歌曲结束。
谢谢
Android
中的自定义 SnackBar尝试创建自定义 Snackbar 布局并在 ImageView
中加载 gif 图像,希望这对您有所帮助并访问 link 以在 ImageView
Load gif in ImageView 中加载 gif
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();