SoFunction
Updated on 2025-04-09

Android Toast implements full screen display

This article shares the specific code for Android Toast full screen display for your reference. The specific content is as follows

Without saying nonsense, just upload the code:

private void toastFullScreen(){
 Toast toast = (this, null, Toast.LENGTH_LONG * 10 * 1000);
 (, 0, 0);
 LinearLayout toastView = (LinearLayout)();
 
 // Get the screen size with unit pixels.
 WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
 DisplayMetrics outMetrics = new DisplayMetrics();
 ().getMetrics(outMetrics);
 
 TextView tv = new TextView(this);
 LayoutParams vlp = new LayoutParams(,
               ); 
 (0, 0, 0, 0);
 (vlp);
 ("Hello Toast! I am full screen now.");
 ();
 
 (tv);
 ();
}

According to the actual situation, adding different views to toastView can display different pop-ups, I hope it will be helpful to everyone!

Another section of custom toast full screen implementation code:

public class MyToast {

  private static Toast mGoodToast;
  private static ObjectAnimator mObjectAnimator;

  public static void showGoodToast(Context context) {

    if (mGoodToast == null) {
      mGoodToast = new Toast(context);
      (, 0, 0);
      (Toast.LENGTH_LONG);
      View view = (context).inflate(.dialog_good, null, false);
      AppCompatImageView imageView = ();
      mObjectAnimator = (imageView, "rotation", 5000);
      (new LinearInterpolator());
      (30000);
      (, 0, 0);
      (view);
      ().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);//Set Toast to be laid out below the system status bar    }

    if (!()) {
      ();
    }
    ();
  }

}

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.