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 getViewBitmap(View v) { if (v.getWidth() == 0 || v.getHeight() == 0) return null; Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.draw(c);/*from w w w. j a v a2 s . c o m*/ return b; }
From source file:Main.java
public static int getXRatio(float x, View v) { return (int) ((x / v.getWidth()) * 100000); }
From source file:Main.java
public static void counterClockwiseRotation90ByCenter(View v) { float w = v.getWidth(); float h = v.getHeight(); RotateAnimation anim = new RotateAnimation(0, 90, w / 2, h / 2); anim.setDuration(10 * 1);//from w w w . j a v a2s . c o m anim.setFillAfter(true); v.startAnimation(anim); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Animator toCenterReveal(View view) { int width = view.getWidth(); int height = view.getHeight(); return ViewAnimationUtils.createCircularReveal(view, width / 2, height / 2, 0, Math.max(width, height)); }
From source file:Main.java
public static float parseRatioToX(int xRatio, View v) { return ((float) xRatio) * v.getWidth() / 100000; }
From source file:Main.java
static public void setPosition(View v, PointF p) { int w = v.getWidth(); int h = v.getHeight(); v.setLeft((int) p.x); v.setTop((int) p.y); v.setRight((int) p.x + w); v.setBottom((int) p.y + h); }
From source file:Main.java
public static void rotateView(@NonNull View rotatedView) { int w = rotatedView.getWidth(), h = rotatedView.getHeight(); int diff = w / 2 - h / 2; rotatedView.setRotation(270);//from w ww . j a v a2s.c om rotatedView.setTranslationX(-diff); }
From source file:Main.java
static int getWidth(View v) { return (v == null) ? 0 : v.getWidth(); }
From source file:Main.java
private static Bitmap getScreenshot(View v) { Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); v.draw(c);/*from w ww . j av a 2s. co m*/ return b; }
From source file:Main.java
public static void measureDynamicHeight(View view) { int width = view.getWidth(); if (width <= 0) { View parent = (View) view.getParent(); width = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight(); }// ww w . j a v a2s . co m int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); view.measure(widthMeasureSpec, heightMeasureSpec); }