public class MyToast { private static Toast mGoodToast; private static ObjectAnimator mObjectAnimator; public static void showGoodToast(Context context) { if (mGoodToast == null) { mGoodToast = new Toast(context); mGoodToast.setGravity(Gravity.CENTER, 0, 0); mGoodToast.setDuration(Toast.LENGTH_LONG); View view = LayoutInflater.from(context).inflate(R.layout.dialog_good, null, false); AppCompatImageView imageView = view.findViewById(R.id.shine); mObjectAnimator = ObjectAnimator.ofFloat(imageView, "rotation", 5000); mObjectAnimator.setInterpolator(new LinearInterpolator()); mObjectAnimator.setDuration(30000); mGoodToast.setGravity(Gravity.FILL, 0, 0); mGoodToast.setView(view); mGoodToast.getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);//设置Toast可以布局到系统状态栏的下面 } if (!mObjectAnimator.isRunning()) { mObjectAnimator.start(); } mGoodToast.show(); } }
自定义toast全屏显示
最新推荐文章于 2024-05-11 02:29:40 发布