List of usage examples for android.view Gravity BOTTOM
int BOTTOM
To view the source code for android.view Gravity BOTTOM.
Click Source Link
From source file:Main.java
public static void showTextToast(Context context, String msg) { if (toast == null) { toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT); } else {//from ww w.jav a 2 s. co m toast.setText(msg); } toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show(); }
From source file:Main.java
public static void showToast(final Activity activity, final String message) { activity.runOnUiThread(new Runnable() { @Override/* w w w . j a v a 2 s . co m*/ public void run() { Toast toast = Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.BOTTOM, 0, 80); toast.show(); } }); }
From source file:Main.java
/**Toast dialog with string */ public static void showToast(final String message, final Activity activity) { final Toast toast = Toast.makeText(activity, message, Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show();// w ww . j a v a 2 s .c o m }
From source file:Main.java
public static void showTip(Context context, String text, boolean isInter) { if (null == showToast) { showToast = Toast.makeText(context, text, Toast.LENGTH_SHORT); } else {//from www .j a v a 2s . com if (isInter) { showToast.cancel(); showToast = Toast.makeText(context, text, Toast.LENGTH_SHORT); } else { showToast.setText(text); } } showToast.setGravity(Gravity.BOTTOM, 0, 0); showToast.show(); }
From source file:Main.java
private static void onCenterDraw(TextView view, Canvas canvas, Drawable drawable, int gravity) { int drawablePadding = view.getCompoundDrawablePadding(); int ratio = 1; float total;/*from www.j av a2s .c o m*/ switch (gravity) { case Gravity.END: ratio = -1; case Gravity.START: total = view.getPaint().measureText(view.getText().toString()) + drawable.getIntrinsicWidth() + drawablePadding + view.getPaddingLeft() + view.getPaddingRight(); canvas.translate(ratio * (view.getWidth() - total) / 2, 0); break; case Gravity.BOTTOM: ratio = -1; case Gravity.TOP: Paint.FontMetrics fontMetrics = view.getPaint().getFontMetrics(); total = fontMetrics.descent - fontMetrics.ascent + drawable.getIntrinsicHeight() + drawablePadding + view.getPaddingTop() + view.getPaddingBottom(); canvas.translate(0, ratio * (view.getHeight() - total) / 2); break; } }
From source file:Main.java
public final static int[] getPopupPosition(View anchor, int gravity) { int[] position = new int[2]; int windowWidth = anchor.getRootView().getMeasuredWidth(); int windowHeight = anchor.getRootView().getMeasuredHeight(); int anchorWidth = anchor.getMeasuredWidth(); int anchorHeight = anchor.getMeasuredHeight(); int[] location = new int[2]; anchor.getLocationInWindow(location); if (Gravity.LEFT == (gravity & Gravity.LEFT)) { position[0] = location[0];// w w w . j av a2 s .c o m } else if (Gravity.RIGHT == (gravity & Gravity.RIGHT)) { position[0] = windowWidth - location[0] - anchorWidth; } if (Gravity.TOP == (gravity & Gravity.TOP)) { position[1] = location[1] + anchorHeight; } else if (Gravity.BOTTOM == (gravity & Gravity.BOTTOM)) { position[1] = windowHeight - location[1]; } return position; }
From source file:Main.java
public static void showMessage(final Context act, final String msg, final int len) { new Thread(new Runnable() { public void run() { handler.post(new Runnable() { @Override/*from w w w .j a va2 s .c om*/ public void run() { if (toast != null) { // toast.cancel(); toast.setText(msg); // toast.setDuration(len); } else { toast = Toast.makeText(act, msg, len); toast.setGravity(Gravity.BOTTOM, 0, 100); } toast.show(); } }); } }).start(); }
From source file:Main.java
static void preDraw(TextView view, Canvas canvas) { Drawable[] drawables = view.getCompoundDrawables(); if (drawables[0] != null) { view.setGravity(Gravity.CENTER_VERTICAL | Gravity.START); onCenterDraw(view, canvas, drawables[0], Gravity.START); } else if (drawables[1] != null) { view.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); onCenterDraw(view, canvas, drawables[1], Gravity.TOP); } else if (drawables[2] != null) { view.setGravity(Gravity.CENTER_VERTICAL | Gravity.END); onCenterDraw(view, canvas, drawables[2], Gravity.END); } else if (drawables[3] != null) { view.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); onCenterDraw(view, canvas, drawables[3], Gravity.BOTTOM); }// w w w .j a va2s. c o m }
From source file:Main.java
public static void preDraw(TextView view, Canvas canvas) { Drawable[] drawables = view.getCompoundDrawables(); if (drawables != null) { if (drawables[0] != null) { view.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); onCenterDraw(view, canvas, drawables[0], Gravity.LEFT); } else if (drawables[1] != null) { view.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); onCenterDraw(view, canvas, drawables[1], Gravity.TOP); } else if (drawables[2] != null) { view.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT); onCenterDraw(view, canvas, drawables[2], Gravity.RIGHT); } else if (drawables[3] != null) { view.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); onCenterDraw(view, canvas, drawables[3], Gravity.BOTTOM); }// w w w . j av a 2s . c o m } }
From source file:Main.java
public static void showAsPopup(Activity activity) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { return;// w w w . j ava 2 s . c o m } activity.requestWindowFeature(Window.FEATURE_ACTION_BAR); //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest Window window = activity.getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); Display display = activity.getWindowManager().getDefaultDisplay(); WindowManager.LayoutParams params = window.getAttributes(); params.height = (int) (display.getHeight() * 0.95); params.width = Math.min((int) (display.getWidth() * 0.9), (int) (params.height * 0.85)); params.gravity = Gravity.BOTTOM; params.alpha = 1.0f; params.dimAmount = 0.5f; window.setAttributes(params); }