Advertisement
SenpaiZero

Custom Toast

Mar 12th, 2024 (edited)
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. private void showCustomToast_main(String message, long duration)
  2.     {
  3.         final TextView toastText = customCardView.findViewById(R.id.toast_text);
  4.         toastText.setText(message);
  5.  
  6.         customCardView.setVisibility(View.VISIBLE);
  7.  
  8.         ObjectAnimator fadeOut = ObjectAnimator.ofFloat(customCardView, "alpha", 1f, 0f);
  9.         fadeOut.setDuration(duration);
  10.  
  11.         fadeOut.addListener(new AnimatorListenerAdapter() {
  12.             @Override
  13.             public void onAnimationEnd(Animator animation) {
  14.                 super.onAnimationEnd(animation);
  15.                 customCardView.setVisibility(View.GONE);
  16.             }
  17.         });
  18.  
  19.         fadeOut.start();
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement