List of usage examples for android.view View getHeight
@ViewDebug.ExportedProperty(category = "layout") public final int getHeight()
From source file:Main.java
public static boolean isEventInView(MotionEvent ev, View view) { int[] location = new int[2]; view.getLocationInWindow(location);// w ww. j a va2s .c o m if (ev.getX() > location[0] && ev.getX() < location[0] + view.getWidth() && ev.getY() > location[1] && ev.getY() < location[1] + view.getHeight()) { return true; } return false; }
From source file:Main.java
public static Rect getRectInScreen(View view) { Rect rect = new Rect(); int[] loc = new int[2]; view.getLocationOnScreen(loc);/* w w w .ja v a 2 s . c o m*/ rect.left = loc[0]; rect.top = loc[1]; rect.right = loc[0] + view.getWidth(); rect.bottom = loc[1] + view.getHeight(); return rect; }
From source file:Main.java
public static boolean pointInView(float x, float y, View v) { if (v == null) return false; int[] location = new int[2]; v.getLocationInWindow(location);/*from www . ja v a2 s. c o m*/ return x >= location[0] && x < (location[0] + v.getWidth()) && y >= location[1] && y < (location[1] + v.getHeight()); }
From source file:Main.java
public static Point getLocationInView(View src, View target) { final int[] l0 = new int[2]; src.getLocationOnScreen(l0);/*from www. j a v a2 s . c om*/ final int[] l1 = new int[2]; target.getLocationOnScreen(l1); l1[0] = l1[0] - l0[0] + target.getWidth() / 2; l1[1] = l1[1] - l0[1] + target.getHeight() / 2; return new Point(l1[0], l1[1]); }
From source file:Main.java
public static Point getPointOnView(View root, View target) { final int[] l0 = new int[2]; root.getLocationOnScreen(l0);/*from ww w . j av a2 s . co m*/ final int[] l1 = new int[2]; target.getLocationOnScreen(l1); l1[0] = l1[0] - l0[0] + target.getWidth() / 2; l1[1] = l1[1] - l0[1] + target.getHeight() / 2; return new Point(l1[0], l1[1]); }
From source file:Main.java
public static void dispatchTouch(final View view, final long duration) { final long downTime = SystemClock.uptimeMillis(); final long eventTime = SystemClock.uptimeMillis(); final float x = view.getWidth() / 3;//0.0f; final float y = view.getHeight() / 3;//0.0f; // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState() final int metaState = 0; MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, metaState); // Dispatch touch event to view view.dispatchTouchEvent(motionEvent); new Handler().postDelayed(new Runnable() { @Override// w w w . j a va 2 s.c o m public void run() { MotionEvent motionEvent = MotionEvent.obtain(downTime + duration, eventTime + duration, MotionEvent.ACTION_UP, x, y, metaState); view.dispatchTouchEvent(motionEvent); } }, duration); }
From source file:Main.java
public static int getScrollY(ListView listView) { View c = listView.getChildAt(0); if (c == null) { return 0; }//from ww w. j a v a2s .c o m int firstVisiblePosition = listView.getFirstVisiblePosition(); int top = c.getTop(); return -top + firstVisiblePosition * c.getHeight(); }
From source file:Main.java
public static void circleReveal(final View targetView, int centerX, int centerY, boolean isReverse) { if (targetView == null || !targetView.isAttachedToWindow()) return;/*from ww w .j av a2s .c o m*/ int radius = (int) Math.hypot(targetView.getHeight(), targetView.getWidth()); Animator animator; if (isReverse) { animator = isCircleRevealSupported() ? ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, radius, 0) : createFade(targetView, 1, 0); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { targetView.setVisibility(View.GONE); } }); } else { animator = isCircleRevealSupported() ? ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, 0, radius) : createFade(targetView, 0, 1); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { targetView.setVisibility(View.VISIBLE); } }); } animator.setDuration(DURATION); animator.start(); }
From source file:com.ada.utils.Ui.java
public static Bitmap createBitmapFromView(View v) { Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); v.draw(canvas);/*from w w w .ja v a 2s . co m*/ return bitmap; }
From source file:Main.java
public static void toggleBottomView(View view, boolean isShow, int duration) { if (view != null) { float fromYDelta = 0; float toYDelta = 0; int visibility; if (isShow) { fromYDelta = view.getHeight(); visibility = View.VISIBLE; } else {/*from w w w. java 2 s . co m*/ toYDelta = view.getHeight(); visibility = View.GONE; } if (fromYDelta == toYDelta) { setMeasureSpec(view); if (isShow) { fromYDelta = view.getMeasuredHeight(); } else { toYDelta = view.getMeasuredHeight(); } } view.setAnimation(translate(0, 0, fromYDelta, toYDelta, duration)); view.setVisibility(visibility); } }