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 LinearLayout setProgressBarLayout(Activity activity) { LinearLayout progressBarLayout = new LinearLayout(activity); progressBarLayout.setGravity(Gravity.CENTER); ProgressBar spinner = new ProgressBar(activity); progressBarLayout.addView(spinner);//from ww w . j a v a 2 s . co m activity.addContentView(progressBarLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return progressBarLayout; }
From source file:Main.java
public static void showCenterTextToast(Context context, String msg) { if (toast == null) { toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT); } else {/*from w w w .j a v a 2s.c o m*/ toast.setText(msg); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:Main.java
public static void showShortToastBottom(Context context, int resId) { Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT); TextView v = toast.getView().findViewById(android.R.id.message); if (v != null) v.setGravity(Gravity.CENTER); toast.show();/*from w ww .j a va 2 s . c om*/ }
From source file:Main.java
/** * Shows a short toast display/*from ww w .j a va 2s .c o m*/ * * @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, String strMsg) { Toast toast = Toast.makeText(context, strMsg, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(1000);//from w w w . j av a 2 s. c om toast.show(); }
From source file:Main.java
public static Toast alert(Context ctx, String message) { Toast t = Toast.makeText(ctx, message, Toast.LENGTH_SHORT); TextView v = (TextView) t.getView().findViewById(android.R.id.message); if (v != null) v.setGravity(Gravity.CENTER); t.show();/*from w w w . j a v a2 s . co m*/ return t; }
From source file:Main.java
/** * Posts a new Toast//from w w w .jav a 2s .c o m * * @param context * @param text * @param duration */ public static void postToast(Context context, CharSequence text) { postToast(context, text, Toast.LENGTH_SHORT, Gravity.CENTER); }
From source file:Main.java
public static void toast(Context mcontext, String toastStr) { toast(mcontext, toastStr, Gravity.CENTER); }
From source file:Main.java
public static void showToast(String message, Context context, int duration) { if (message == null || message.length() == 0) return;/*from w ww. j a va 2 s .c om*/ try { Toast toast = Toast.makeText(context, message, duration); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } catch (Exception e) { // } }
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();/*w w w . j a v a 2s .c o m*/ }