Example usage for android.view View getWidth

List of usage examples for android.view View getWidth

Introduction

In this page you can find the example usage for android.view View getWidth.

Prototype

@ViewDebug.ExportedProperty(category = "layout")
public final int getWidth() 

Source Link

Document

Return the width of your view.

Usage

From source file:Main.java

public static void hideAnimatedView(View view) {
    if (PRE_HC && view != null)
        view.setPadding(view.getWidth(), 0, 0, 0);
}

From source file:Main.java

public static void revealColorFromCoordinates(int x, int y, View viewRoot) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());
    Animator anim = null;//from w  ww . ja  v  a2  s. c o  m
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
    }
    //viewRoot.setBackgroundColor(ContextCompat.getColor(viewRoot.getContext(), R.color.colorPrimary));
    anim.setDuration(1000);
    anim.start();
}

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);/*from  ww w. j  a v a  2  s.c  o m*/

    return bitmap;
}

From source file:Main.java

public static Bitmap getBitmapFromView(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.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 ava 2s.  c o m

    return bitmap;
}

From source file:Main.java

/**
 * Returns a bitmap showing a screenshot of the view passed in.
 *///  w ww  .  jav  a2  s.  com
public static Bitmap getBitmapFromView(final View v) {
    Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    v.draw(canvas);
    return bitmap;
}

From source file:Main.java

/**
 * Draws view to a bitmap image./*from ww  w.j ava  2 s .co m*/
 */
public static Bitmap drawToBitmap(final View viewToDraw) {

    final Bitmap bitmap = Bitmap.createBitmap(viewToDraw.getWidth(), viewToDraw.getHeight(),
            Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bitmap);
    viewToDraw.draw(canvas);
    return bitmap;
}

From source file:Main.java

public static void appearFromLeft(View target, long duration) {
    Animation animation = new TranslateAnimation(-target.getWidth(), 0, 0, 0);
    animation.setDuration(duration);//from   w w  w  . j  av a2 s .  c  o m
    //      animation.setFillAfter(true);
    target.startAnimation(animation);
    target.setVisibility(View.VISIBLE);
}

From source file:Main.java

public static Bitmap convertView2Bitmap(View view) {
    try {/* w w  w .  j a  v a2s.  co m*/
        Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static Animator createInAnimator(View view) {
    // get the center for the clipping circle
    int cx = view.getWidth() / 2;
    int cy = view.getHeight() / 2;

    // get the final radius for the clipping circle
    int finalRadius = Math.max(view.getWidth(), view.getHeight());

    // create the animator for this view (the start radius is zero)
    return ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius).setDuration(300);
}

From source file:Main.java

public static Bitmap getScreenshotsForCurrentWindow(Activity activity) {
    View cv = activity.getWindow().getDecorView();
    Bitmap bmp = Bitmap.createBitmap(cv.getWidth(), cv.getHeight(), Bitmap.Config.ARGB_4444);
    cv.draw(new Canvas(bmp));
    return bmp;/*from   www .ja  va  2  s. c o m*/
}