Example usage for android.widget Toast setGravity

List of usage examples for android.widget Toast setGravity

Introduction

In this page you can find the example usage for android.widget Toast setGravity.

Prototype

public void setGravity(int gravity, int xOffset, int yOffset) 

Source Link

Document

Set the location at which the notification should appear on the screen.

Usage

From source file:Main.java

@SuppressLint("ShowToast")
public static Toast createToast(Context context, String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0);
    return toast;
}

From source file:Main.java

public static void ShowToastMessage(Context mContext, String xMessage) {
    Toast mToast = Toast.makeText(mContext, xMessage, Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);
    mToast.show();//w w  w  . j a va  2 s . com
}

From source file:Main.java

public static void showToast(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*www.java2s .c o  m*/
}

From source file:Main.java

/**
 * Shows a short toast display/* w ww  .j  av a 2  s. c om*/
 * 
 * @param ctx application context
 * @param message message to display
 */
public static void showToast(Context ctx, String message) {
    Toast toast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();

}

From source file:Main.java

public static void showToast(Context context, int resId) {
    Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*  w  w w .j a  va2s.c o  m*/
}

From source file:Main.java

public static void longToast(int string, Context ctx) {
    Toast t = new Toast(ctx).makeText(ctx, string, Toast.LENGTH_LONG);
    t.setGravity(Gravity.TOP, 0, dpToPx(55, ctx));
    t.show();/*  w  w w. ja v  a2s.  c o  m*/
}

From source file:Main.java

public static void showLToast(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();//from   w  ww  . ja v a 2 s.  c  o  m
}

From source file:Main.java

public static void ShowToast(Context context, String strMsg) {
    Toast toast = Toast.makeText(context, strMsg, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(1000);//from  w  w w .  java 2 s .com
    toast.show();
}

From source file:Main.java

public static void shortToast(int string, Context ctx) {
    Toast t = new Toast(ctx).makeText(ctx, string, Toast.LENGTH_SHORT);
    t.setGravity(Gravity.TOP, 0, dpToPx(55, ctx));
    t.show();//from w ww.  ja v a  2s  .  c  o  m
}

From source file:Main.java

/**
 * Zeigt Positionierten Toast./* ww  w .j  a v  a  2s. c om*/
 * @param _Activity
 * @param _message  Darzustellende Nachricht
 * @param _Gravity  Position des Toasts
 */
public static void showPositionedToast(Activity _Activity, String _message, int _Gravity) {
    Toast toast = Toast.makeText(_Activity, _message, Toast.LENGTH_SHORT);
    toast.setGravity(_Gravity, 0, 120);
    toast.show();
}