Example usage for android.view Gravity CENTER

List of usage examples for android.view Gravity CENTER

Introduction

In this page you can find the example usage for android.view Gravity CENTER.

Prototype

int CENTER

To view the source code for android.view Gravity CENTER.

Click Source Link

Document

Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.

Usage

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();//w  ww  .ja  v a  2s.co m
}

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();//  ww w .ja  v  a2s.  c  o  m

}

From source file:Main.java

public static void showToast_Long(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*ww w  . j  av a2  s.c o m*/
}

From source file:Main.java

public static void makeToastMsg(Context context, String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/* w w w .  j av  a  2 s .com*/
}

From source file:Main.java

public static void showToast_Short(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();//www  .  j  a va 2  s.  co  m
}

From source file:Main.java

public static void ShowToastCenter(Context context, String strText, int nTime) {
    if (context != null) {
        Toast toast = Toast.makeText(context, strText, nTime);

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

        toast.show();//from  w  w  w  .  j av a 2s.  c  o  m
    }

}

From source file:Main.java

public static void makeShortToast(Context ctx, String message) {

    if (ctx != null && message != null) {

        Toast toast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 50);
        toast.show();/*www .  j  a  v a  2  s . com*/
    }
}

From source file:Main.java

public static TextView createTextView(Context context, String text) {
    TextView tv = new TextView(context);
    tv.setPadding(10, 10, 10, 10);/*from   w ww  .ja  v a2s .c o  m*/
    tv.setText(text);
    tv.setGravity(Gravity.CENTER);
    tv.setTextSize(24);
    tv.setTextColor(Color.RED);
    return tv;
}

From source file:Main.java

/**
 * //from  w ww . j  a  va2 s .  co  m
 * @param context
 * @param text
 */
public static void showLong(Context context, CharSequence text) {
    showLong(context, text, Gravity.CENTER);
}

From source file:Main.java

/**
 * /*w  w  w .j  a v a2 s  . co m*/
 * @param context
 * @param text
 */
public static void showShort(Context context, CharSequence text) {
    showShort(context, text, Gravity.CENTER);
}