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

public static void showToastBottom(Context context, String s) {
    Toast toast = Toast.makeText(context, s, 0);
    toast.setGravity(81, 0, 80);
    toast.show();/*from   w ww.ja  v a  2  s  . co m*/
}

From source file:Main.java

public static void showToast(Context context, String text, int duration) {
    Toast toast = Toast.makeText(context, text, duration);
    toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    toast.show();//from  w  w w  .j  a  v a2s  .co m
}

From source file:Main.java

public static void showToast(Context c, String str) {
    Toast toast = Toast.makeText(c, str, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, toast.getXOffset() / 2, toast.getYOffset() / 2);
    toast.show();//  w ww . j a v a  2  s  .  c  o m
}

From source file:Main.java

public static void showMiddleToast(Context cxt, String msg) {
    Toast toast = Toast.makeText(cxt, msg, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*  www.  j  a v  a 2  s.  c  om*/
}

From source file:Main.java

public static void showToast(Context context, String text) {
    Toast t = Toast.makeText(context, text, Toast.LENGTH_LONG);
    t.setGravity(Gravity.CENTER, 0, 0);
    t.show();/*from   w  ww .  j ava 2s  .c om*/
}

From source file:Main.java

public static void showCenterShortToast(String text, Context ctx) {

    int duration = Toast.LENGTH_SHORT;

    Toast toast = Toast.makeText(ctx, text, duration);

    toast.setGravity(Gravity.CENTER, 0, 0);

    toast.show();/*from   w ww  .  j  ava  2 s.co  m*/

}

From source file:Main.java

public static void showToast(Context context, int resId, int time) {
    Toast toast = Toast.makeText(context, resId, time);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();//from  ww  w.j a v a2  s .c  om
}

From source file:Main.java

public static void show(Context context, String info) {
    Toast t = Toast.makeText(context, info, Toast.LENGTH_LONG);
    t.setGravity(Gravity.CENTER, 0, 0);
    t.show();//from   www . j a va2s.c o  m
}

From source file:Main.java

public static void show(Context context, int info) {
    Toast t = Toast.makeText(context, info, Toast.LENGTH_LONG);
    t.setGravity(Gravity.CENTER, 0, 0);
    t.show();//ww  w . j ava  2 s . co  m
}

From source file:Main.java

public static void showToast(Context context, String msg) {
    Toast toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();//from   w  ww.j a  va  2  s .  com
}