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

public static void drawLeftAlignItem(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.getLeft() - params.leftMargin - drawable.getIntrinsicWidth();
    final int right = left + drawable.getIntrinsicWidth();

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

    drawable.draw(canvas);//from w  w  w.  j  av  a2s  .co  m
}

From source file:Main.java

public static float getVisibilityPercentage(AbsListView listView) {
    int firstVisible = listView.getFirstVisiblePosition();
    if (firstVisible > 0)
        return -1;
    int childCount = listView.getChildCount();
    if (childCount == 0)
        return -1;

    View firstChild = listView.getChildAt(0);

    int topOffset = firstChild.getTop();
    int padding = listView.getPaddingTop();

    return topOffset / (float) padding;

}

From source file:Main.java

public static void invalidateGlobalRegion(View view) {
    invalidateGlobalRegion(view, new RectF(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()));
}

From source file:Main.java

public static boolean pointInView(@NonNull View view, float localX, float localY, float slop) {
    return localX >= view.getLeft() - slop && localX < view.getRight() + slop && localY >= view.getTop() - slop
            && localY < view.getBottom() + slop;
}

From source file:Main.java

public static boolean pointInView(View view, float localX, float localY) {
    return localX >= 0 && localX < (view.getRight() - view.getLeft()) && localY >= 0
            && localY < (view.getBottom() - view.getTop());
}

From source file:Main.java

public static boolean isMotionOnView(View view, MotionEvent event) {
    final float x = event.getX();
    final float y = event.getY();
    if (x < view.getRight() && x > view.getLeft() && y < view.getBottom() && y > view.getTop()) {
        return true;
    }//from  w  ww . j  a  v a  2 s  . co m
    return false;
}

From source file:Main.java

/**
 * Utility method to determine whether the given point, in local coordinates,
 * is inside the view, where the area of the view is expanded by the slop factor.
 * This method is called while processing touch-move events to determine if the event
 * is still within the view.//w w  w. j ava  2s . c  om
 */
private static boolean pointInView(View v, float localX, float localY, float slop) {
    return localX >= -slop && localY >= -slop && localX < ((v.getRight() - v.getLeft()) + slop)
            && localY < ((v.getBottom() - v.getTop()) + slop);
}

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   w w w .  j  a va  2 s  . c  o  m

    return bitmap;
}

From source file:Main.java

public static int getScrollY(ListView listView) {
    View c = listView.getChildAt(0);
    if (c == null) {
        return 0;
    }/*  w ww.j  a  v a  2 s .  com*/

    int firstVisiblePosition = listView.getFirstVisiblePosition();
    int top = c.getTop();

    return -top + firstVisiblePosition * c.getHeight();
}

From source file:Main.java

public static BitmapDrawable createDrawableFromView(Context context, View v) {
    Bitmap b = Bitmap.createBitmap(v.getLayoutParams().width, v.getLayoutParams().height,
            Bitmap.Config.ARGB_8888);//  w  w  w.  j  av  a 2s  .  c  om
    Canvas c = new Canvas(b);
    v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    v.draw(c);
    return new BitmapDrawable(context.getResources(), b);
}