Apply frame animation to toast view

Can I play frame animation in Toast view?

Lines 3-5 in the code below is what usually works for me if I want to play a frame animation in a view. Unfortunately, when I try to apply this view to a toast object, it does not liven up when a toast is displayed. Does anyone know if it is possible to play a frame animation on a toast? If so, how? thank

LayoutInflater inflaterSpin = getLayoutInflater();
View layout = inflaterSpin.inflate(R.layout.toast_layout, (ViewGroup)   findViewById(R.id.toast_layout_root));

layout.setBackgroundResource(R.anim.anim_toast);
AnimationDrawable toastAnim = (AnimationDrawable) layout.getBackground();
toastAnim.start();

myToast = new Toast(getApplicationContext());             
myToast.setView(layoutSpin);
myToast.show();
+3
source share
1 answer

-, ? issue toastAnim.start(); . . .. Goodluck. , , Activity.

. xml , R.drawable.frameanim, R.anim.frameanim

+2

Source: https://habr.com/ru/post/1758240/


All Articles