List of usage examples for android.view View getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:Main.java
public static Bitmap createBitmap(View v) { Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.draw(canvas);// ww w. j av a 2 s . c om return bitmap; }
From source file:Main.java
public static Bitmap createViewBitmap(View v) { Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.draw(canvas);/*from ww w .j av a 2 s. c o m*/ return bitmap; }
From source file:Main.java
public static float getDistanceToCenterX(View target) { float viewCenter = target.getLeft() + target.getWidth() / 2f; float rootCenter = ((View) target.getParent()).getWidth() / 2; return target.getWidth() / 2f + rootCenter - viewCenter; }
From source file:Main.java
public static Bitmap toBitmap(View v) { int w = v.getWidth(); int h = v.getHeight(); if (w <= 0 || h <= 0) { return null; }/* w w w . j a v a2 s . c o m*/ Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.draw(canvas); return bitmap; }
From source file:Main.java
public static Bitmap convertViewToBitmap(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); view.draw(new Canvas(bitmap)); return bitmap; }
From source file:Main.java
public static Bitmap viewToBitmap(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas);/*from w w w. j a v a 2s .c o m*/ return bitmap; }
From source file:Main.java
public static Bitmap getBitmap(View view) { int width = view.getWidth(); int height = view.getHeight(); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); canvas.translate(-view.getScrollX(), -view.getScrollY()); view.draw(canvas);/*from w w w.ja v a 2 s . c o m*/ return bitmap; }
From source file:Main.java
public static Bitmap createBitmap(View target) { Bitmap b = Bitmap.createBitmap(target.getWidth(), target.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); target.draw(c);//www . j av a2 s . co m /* enable this to invert the image: */ //invertImage(b); return b; }
From source file:Main.java
/** * Returns the descendant's frame relative to the parent. Applies conversion if views are * between the descendant and the parent. * * @param parent the returned frame will be relative to this view * @param descendant any view underneath the parent view. * @return the descendant's frame in parent view coordinates *///from w ww. j av a 2 s .c o m public static Rect convertedRectForDescendant(ViewGroup parent, View descendant) { Rect result = new Rect(0, 0, descendant.getWidth(), descendant.getHeight()); // alternately: descendant.getDrawingRect() ? parent.offsetDescendantRectToMyCoords(descendant, result); return result; }
From source file:Main.java
/** * Post translates the matrix to center the given bounds inside the view. *//*from w w w . j ava2 s . c om*/ public static void postCenterMatrix(RectF contentBounds, View view, Matrix matrix) { matrix.postTranslate((view.getWidth() - contentBounds.width()) / 2, (view.getHeight() - contentBounds.height()) / 2); }