Example usage for android.view View getTop

List of usage examples for android.view View getTop

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final int getTop() 

Source Link

Document

Top position of this view relative to its parent.

Usage

From source file:Main.java

/**
 * @param view//from   w w w.  j  av  a2  s  .  co  m
 * @return
 */
public static boolean isReset(View view) {
    return view.getTop() == view.getY();
}

From source file:Main.java

public static float getDistanceToCenter(View target) {
    float viewCenter = target.getTop() + target.getHeight() / 2f;
    float rootCenter = ((View) target.getParent()).getHeight() / 2;
    return target.getHeight() / 2f + rootCenter - viewCenter;
}

From source file:Main.java

static public Rect getFrame(View v) {
    return new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
}

From source file:Main.java

static public PointF getPosition(View v) {
    return new PointF(v.getLeft(), v.getTop());
}

From source file:Main.java

public static float getViewY(View view) {
    return Math.abs((view.getBottom() - view.getTop()) / 2);
}

From source file:Main.java

static public Rect getPaddedFrame(View v) {
    return new Rect(v.getLeft() + v.getPaddingLeft(), v.getTop() + v.getPaddingTop(),
            v.getRight() - v.getPaddingRight(), v.getBottom() - v.getPaddingBottom());
}

From source file:Main.java

public static void drawLeft(Canvas canvas, Drawable drawable, View child, ViewGroup.MarginLayoutParams params) {

    final int top = child.getTop() - params.topMargin - drawable.getIntrinsicHeight();
    final int bottom = child.getBottom() + params.bottomMargin + drawable.getIntrinsicHeight();
    final int left = child.getLeft() - params.leftMargin - drawable.getIntrinsicWidth();
    final int right = left + drawable.getIntrinsicWidth();

    drawable.setBounds(left, top, right, bottom);

    drawable.draw(canvas);/*from  w  w w . jav  a2s  .c om*/
}

From source file:Main.java

/**
 * Methods used for the slider/*from ww w.j a  v  a 2s  . co  m*/
 */

public static int getRelativeTop(View myView) {
    if (myView.getId() == android.R.id.content)
        return myView.getTop();
    else
        return myView.getTop() + getRelativeTop((View) myView.getParent());
}

From source file:Main.java

public static void drawRight(Canvas canvas, Drawable drawable, View child,
        ViewGroup.MarginLayoutParams params) {

    final int top = child.getTop() - params.topMargin - drawable.getIntrinsicHeight();
    final int bottom = child.getBottom() + params.bottomMargin + drawable.getIntrinsicHeight();
    final int left = child.getRight() + params.rightMargin;
    final int right = left + drawable.getIntrinsicWidth();

    drawable.setBounds(left, top, right, bottom);
    drawable.draw(canvas);//from   w w  w  .j  a va2 s  .co m
}

From source file:Main.java

public static void drawRightAlignItem(Canvas canvas, Drawable drawable, View child,
        ViewGroup.MarginLayoutParams params) {

    final int top = child.getTop() - params.topMargin;
    final int bottom = child.getBottom() + params.bottomMargin;
    final int left = child.getRight() + params.rightMargin;
    final int right = left + drawable.getIntrinsicWidth();

    drawable.setBounds(left, top, right, bottom);
    drawable.draw(canvas);// ww  w .  j a v a2  s.  com
}