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 final void showToast(Context context, String tip, boolean isCenter) { int duration = Toast.LENGTH_SHORT; if (TextUtils.isEmpty(tip)) { return;//from w w w .j av a2s . c o m } if (tip.length() >= 15) { duration = Toast.LENGTH_LONG; } Toast toast = Toast.makeText(context, tip, duration); if (isCenter) { toast.setGravity(Gravity.CENTER, 0, 0); } toast.show(); }
From source file:Main.java
/** * // w ww.j a va 2 s. c om * @param context * @param resId */ public static void showLong(Context context, int resId) { showLong(context, resId, Gravity.CENTER); }
From source file:Main.java
/** * //from w w w . jav a 2 s.c om * @param context * @param resId */ public static void showShort(Context context, int resId) { showShort(context, resId, Gravity.CENTER); }
From source file:Main.java
public static void toast(Context context, String message, boolean shortDuration) { if (toast == null) { toast = Toast.makeText(context, message, shortDuration ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); } else {/*from w w w . ja va2 s. com*/ toast.setText(message); toast.setDuration(shortDuration ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG); } toast.show(); }
From source file:MainActivity.java
public void showToast(View view) { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toast_custom, null); ((TextView) layout.findViewById(android.R.id.message)).setText("Custom Toast"); Toast toast = new Toast(this); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout);//from ww w .jav a 2s .c o m toast.show(); }
From source file:com.jamesgiang.aussnowcam.Utils.java
public static void About(Context c) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(c); dialogBuilder.setTitle(R.string.app_name); dialogBuilder.setIcon(R.drawable.icon); TextView textView = new TextView(c); SpannableString s = new SpannableString(c.getString(R.string.about_info)); Linkify.addLinks(s, Linkify.WEB_URLS); textView.setText(s);/*w w w. j ava 2s . c om*/ textView.setGravity(Gravity.CENTER); textView.setMovementMethod(LinkMovementMethod.getInstance()); dialogBuilder.setView(textView); dialogBuilder.show(); }
From source file:com.monmonja.library.utils.ViewUtils.java
public static void makeToast(Context context, int resId) { TypedValue tv = new TypedValue(); int offsetY = 0; if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { offsetY = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); }/* w ww . jav a 2 s.c o m*/ Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); View view = toast.getView(); view.setBackgroundColor(context.getResources().getColor(R.color.toast_background)); TextView text = (TextView) view.findViewById(android.R.id.message); text.setTextColor(context.getResources().getColor(android.R.color.white)); toast.show(); }
From source file:com.adstrosoftware.gpsplayground.InvalidFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TextView textView = new TextView(getActivity()); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setText(R.string.illegalFeature); textView.setGravity(Gravity.CENTER); return textView; }
From source file:com.adstrosoftware.animationplayground.InvalidFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TextView textView = new TextView(getActivity()); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); textView.setText(R.string.illegalAnimation); textView.setGravity(Gravity.CENTER); return textView; }
From source file:am.project.x.business.common.LoadingDialog.java
public LoadingDialog(Context context) { super(context, R.style.TransparentDialog); final FrameLayout contentView = new FrameLayout(context); final MaterialProgressImageView loading = new MaterialProgressImageView(context); loading.setColorSchemeColors(ContextCompat.getColor(context, android.R.color.holo_red_light), ContextCompat.getColor(context, android.R.color.holo_blue_light), ContextCompat.getColor(context, android.R.color.holo_green_light), ContextCompat.getColor(context, android.R.color.holo_orange_light), ContextCompat.getColor(context, android.R.color.holo_purple)); contentView.addView(loading, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); setContentView(contentView);//from www. ja v a 2s . c om setCancelable(false); setCanceledOnTouchOutside(false); }