Example usage for android.view View getMeasuredWidth

List of usage examples for android.view View getMeasuredWidth

Introduction

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

Prototype

public final int getMeasuredWidth() 

Source Link

Document

Like #getMeasuredWidthAndState() , but only returns the raw width component (that is the result is masked by #MEASURED_SIZE_MASK ).

Usage

From source file:com.fastbootmobile.encore.utils.Utils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void animateHeadingHiding(final View view, final long duration) {
    final int cx = view.getMeasuredWidth() / 5;
    final int cy = view.getMeasuredHeight() / 2;
    animateHeadingHiding(view, cx, cy, duration);
}

From source file:com.fastbootmobile.encore.utils.Utils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void animateHeadingReveal(final View view, final long duration) {
    final int cx = view.getMeasuredWidth() / 5;
    final int cy = view.getMeasuredHeight() / 2;
    final int radius = Utils.getEnclosingCircleRadius(view, cx, cy);
    if (cx == 0 && cy == 0) {
        Log.w(TAG, "animateHidingReveal: Measured dimensions are zero");
    }//  w  w w .  j  a  v  a2 s .c om
    animateCircleReveal(view, cx, cy, 0, radius, duration);
}

From source file:com.desmond.ripple.view.RippleCompat.java

private static void measure(final RippleCompatDrawable drawable, final View v) {
    if (v instanceof Button) {
        fitButton(drawable, v instanceof AppCompatButton);
    } else if (v instanceof EditText) {
        fitEditText(drawable, v instanceof AppCompatEditText);
    }/*from  w  w  w  . j  av a 2s.co  m*/
    v.setFocusableInTouchMode(true);
    v.setOnTouchListener(new ForwardingTouchListener(drawable, v));
    v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            int radius = Math.max(v.getMeasuredWidth(), v.getMeasuredHeight());
            drawable.setMeasure(v.getMeasuredWidth(), v.getMeasuredHeight());
            if (drawable.isFull())
                drawable.setMaxRippleRadius(radius);
        }
    });
}

From source file:com.fastbootmobile.encore.utils.Utils.java

public static void animateScale(View v, boolean animate, boolean visible) {
    v.setPivotX(v.getMeasuredWidth() / 2);
    v.setPivotY(v.getMeasuredHeight() / 2);

    if (visible) {
        if (animate) {
            v.animate().scaleX(1.0f).scaleY(1.0f).alpha(1.0f).translationY(0.0f).setDuration(400)
                    .setInterpolator(new DecelerateInterpolator()).start();
        } else {/*from w ww  .j  a  va 2s.  c om*/
            v.setScaleX(1.0f);
            v.setScaleY(1.0f);
            v.setAlpha(1.0f);
            v.setTranslationY(0.0f);
        }
    } else {
        if (animate) {
            v.animate().scaleX(0.0f).scaleY(0.0f).alpha(0.0f).translationY(v.getHeight() / 4).setDuration(400)
                    .setInterpolator(new DecelerateInterpolator()).start();
        } else {
            v.setScaleX(0.0f);
            v.setScaleY(0.0f);
            v.setAlpha(0.0f);
            v.setTranslationY(v.getHeight() / 4);
        }
    }
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * First part of the click animation.// ww w . java  2 s .  c  o  m
 *
 * @param context Any context.
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimDown(Context context, View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = new View(context);
    rectView.setId(R.id.rect_view_id);
    rectView.setVisibility(View.GONE);
    rectView.setBackgroundResource(R.drawable.square);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getMeasuredWidth(),
            v.getMeasuredHeight());
    params.addRule(RelativeLayout.ALIGN_TOP, v.getId());
    rectView.setLayoutParams(params);
    AlphaAnimation rectAnim = new AlphaAnimation(0f, 0.4f);
    rectAnim.setFillAfter(true);
    rectAnim.setInterpolator(new AccelerateInterpolator());
    rectAnim.setDuration(150);
    rectAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            rectView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    root.addView(rectView);
    rectView.startAnimation(rectAnim);
}

From source file:com.freshdigitable.udonroad.TimelineAnimator.java

private static void clearAllAnimationSettings(View v) {
    ViewCompat.setAlpha(v, 1);/*  w  ww.j  ava  2  s.  c  om*/
    ViewCompat.setScaleX(v, 1);
    ViewCompat.setScaleY(v, 1);
    ViewCompat.setTranslationX(v, 0);
    ViewCompat.setTranslationY(v, 0);
    ViewCompat.setRotationX(v, 0);
    ViewCompat.setRotationY(v, 0);
    ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
    ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
    ViewCompat.animate(v).setInterpolator(null).setStartDelay(0);
}

From source file:Main.java

public static Rect getLocationInView(View parent, View child) {
    if (child == null || parent == null) {
        throw new IllegalArgumentException("parent and child can not be null .");
    }// w w  w.j  ava 2 s .  c o  m

    View decorView = null;
    Context context = child.getContext();
    if (context instanceof Activity) {
        decorView = ((Activity) context).getWindow().getDecorView();
    }

    Rect result = new Rect();
    Rect tmpRect = new Rect();

    View tmp = child;

    if (child == parent) {
        child.getHitRect(result);
        return result;
    }
    while (tmp != decorView && tmp != parent) {
        tmp.getHitRect(tmpRect);
        if (!tmp.getClass().equals(FRAGMENT_CON)) {
            result.left += tmpRect.left;
            result.top += tmpRect.top;
        }
        tmp = (View) tmp.getParent();
    }
    result.right = result.left + child.getMeasuredWidth();
    result.bottom = result.top + child.getMeasuredHeight();
    return result;
}

From source file:android.support.v7.view.menu.MenuPopup.java

/**
 * Measures the width of the given menu view.
 *
 * @param view The view to measure.//from  w  w w  . j  a va 2s .  c o m
 * @return The width.
 */
protected static int measureIndividualMenuWidth(ListAdapter adapter, ViewGroup parent, Context context,
        int maxAllowedWidth) {
    // Menus don't tend to be long, so this is more sane than it looks.
    int maxWidth = 0;
    View itemView = null;
    int itemType = 0;

    final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }

        if (parent == null) {
            parent = new FrameLayout(context);
        }

        itemView = adapter.getView(i, itemView, parent);
        itemView.measure(widthMeasureSpec, heightMeasureSpec);

        final int itemWidth = itemView.getMeasuredWidth();
        if (itemWidth >= maxAllowedWidth) {
            return maxAllowedWidth;
        } else if (itemWidth > maxWidth) {
            maxWidth = itemWidth;
        }
    }

    return maxWidth;
}

From source file:com.animedetour.android.view.animator.SlideInLeftAnimator.java

public int getWidth(View itemView) {
    return itemView.getMeasuredWidth() + itemView.getPaddingRight()
            + ((RecyclerView.LayoutParams) itemView.getLayoutParams()).rightMargin;
}

From source file:com.asc_ii.bangnote.bigbang.BigBangActionBar.java

private void layoutSubView(View view, int l, int t) {
    view.layout(l, t, view.getMeasuredWidth() + l, view.getMeasuredHeight() + t);
}