List of usage examples for android.view View layout
@SuppressWarnings({ "unchecked" }) public void layout(int l, int t, int r, int b)
This is the second phase of the layout mechanism.
From source file:Main.java
/** * Returns a bitmap from the views drawing cache. Warining: disables drawing * cache after usage./*from w ww .jav a 2s . co m*/ * * @param view * @return */ public static Bitmap getBitmapFromView(View view) { view.setDrawingCacheEnabled(true); view.layout(0, 0, view.getWidth(), view.getBottom()); view.buildDrawingCache(); Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(false); return bitmap; }
From source file:Main.java
public static void layoutView(View v, int width, int height) { // validate view.width and view.height v.layout(0, 0, width, height); int measuredWidth = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY); int measuredHeight = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY); // validate view.measurewidth and view.measureheight v.measure(measuredWidth, measuredHeight); v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); }
From source file:Main.java
public static void prepareViewToGetSize(View view) { view.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); }
From source file:Main.java
public static Bitmap getBitmapFromView(View paramView) { paramView.destroyDrawingCache();//from www. j ava 2 s .co m paramView.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0)); paramView.layout(0, 0, paramView.getMeasuredWidth(), paramView.getMeasuredHeight()); paramView.setDrawingCacheEnabled(true); return paramView.getDrawingCache(true); }
From source file:Main.java
public static Drawable convertViewToDrawable(View view) { int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); view.measure(spec, spec);//from w w w .ja v a 2s . c o m view.layout(UPPER_LEFT_X, UPPER_LEFT_Y, view.getMeasuredWidth(), view.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); c.translate(-view.getScrollX(), -view.getScrollY()); view.draw(c); view.setDrawingCacheEnabled(true); Bitmap cacheBmp = view.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); view.destroyDrawingCache(); return new BitmapDrawable(viewBmp); }
From source file:Main.java
public static Bitmap convertViewToBitmap(View view) { view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.buildDrawingCache();//from ww w . ja va2s. c om Bitmap bitmap = view.getDrawingCache(); return bitmap; }
From source file:Main.java
public static Bitmap getBitmapFromView(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); view.draw(canvas);/* w w w . j a v a2s . c o m*/ return bitmap; }
From source file:Main.java
public static void prepareViewToGetSize(View view) { view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); }
From source file:Main.java
public static Bitmap convertViewToBitmap(View view) { view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.buildDrawingCache();/*w ww .ja v a2 s. c o m*/ return view.getDrawingCache(); }
From source file:Main.java
public static Bitmap loadBitmapFromView(View v) { Bitmap b = Bitmap.createBitmap(v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);/* w w w. java2 s . c o m*/ Canvas c = new Canvas(b); v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height); v.draw(c); return b; }