List of usage examples for android.view Gravity CENTER
int CENTER
To view the source code for android.view Gravity CENTER.
Click Source Link
From source file:Main.java
public static Toast alert(Context ctx, int nResID) { Toast t = Toast.makeText(ctx, nResID, Toast.LENGTH_SHORT); TextView v = (TextView) t.getView().findViewById(android.R.id.message); if (v != null) v.setGravity(Gravity.CENTER); t.show();//w w w . ja v a 2s . c om return t; }
From source file:Main.java
public static void show(Context paramContext, CharSequence paramCharSequence) { if (paramContext == null) { return;/*w w w. j a va 2s. c o m*/ } if (toast == null) { toast = Toast.makeText(paramContext, paramCharSequence, Toast.LENGTH_SHORT); } else { toast.setText(paramCharSequence); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:Main.java
public static void showCenteredToast(Context context, CharSequence text, int duration) { Toast toast = Toast.makeText(context, text, duration); TextView v = (TextView) toast.getView().findViewById(android.R.id.message); if (v != null) { v.setGravity(Gravity.CENTER); }//from ww w . j a va 2 s .c om toast.show(); }
From source file:Main.java
/** * Show toast message./*from www . ja v a 2 s . c o m*/ * * @param context Context * @param message Text to display */ public static void ShowMessage(Context context, String message) { if (context != null) { if (TOAST != null) { TOAST.cancel(); } Toast newToast = Toast.makeText(context, message, message.length() < 15 ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG); TextView textView = (TextView) newToast.getView().findViewById(android.R.id.message); textView.setGravity(Gravity.CENTER); textView.setSingleLine(false); newToast.show(); TOAST = newToast; } }
From source file:Main.java
public static void showToast(Context context, String title) { Toast toast = Toast.makeText(context, title, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();// w w w .j av a 2 s.co m }
From source file:Main.java
/***************************************************************************** * Function: serviceToast//from w ww. j a v a 2 s. co m * Date March 5, 2015 * Revision: * * Designer: Jeff Bayntun * *Programmer: Jeff Bayntun * *Interface: void serviceToast(Context c, String text, int duration) * Activity c -- Current activity * String text -- toast text * int duration -- duration of the toast * *Returns: * void * * Notes: * Creates a toast on the screen. **************************************************************************/ public static void serviceToast(Context c, String text, int duration) { Toast t = Toast.makeText(c, text, duration); t.setGravity(Gravity.CENTER, 0, 0); t.show(); }
From source file:Main.java
public static void showCenter(Context context, CharSequence text) { toast(context, text, LENGTH_SHORT, Gravity.CENTER, 0, 0); }
From source file:Main.java
private static void addDivider(final ViewGroup stripView, final View dividerView) { stripView.addView(dividerView);//w ww . j av a 2 s . com final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) dividerView.getLayoutParams(); params.gravity = Gravity.CENTER; }
From source file:Main.java
public static void showCenteredToast(Context context, int resId, int duration) { Toast toast = Toast.makeText(context, resId, duration); TextView v = (TextView) toast.getView().findViewById(android.R.id.message); if (v != null) { v.setGravity(Gravity.CENTER); }/*from ww w. ja v a 2 s. c o m*/ toast.show(); }
From source file:Main.java
public static void showToast(Context context, View view) { Toast toast = new Toast(context); toast.setView(view);//from w ww . j a v a2s. c o m toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show(); }