List of usage examples for android.view View getTop
@ViewDebug.CapturedViewProperty public final int getTop()
From source file:Main.java
public static int getScrollY(ListView lv) { View c = lv.getChildAt(0); if (c == null) { return 0; }/*from www . java2 s . co m*/ int firstVisiblePosition = lv.getFirstVisiblePosition(); int top = c.getTop(); int scrollY = -top + firstVisiblePosition * c.getHeight(); return scrollY; }
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);//from w w w . ja v a 2 s . c o m return bitmap; }
From source file:Main.java
public static void drawTopAlignItem(Canvas canvas, Drawable drawable, View child, ViewGroup.MarginLayoutParams params) { final int left = child.getLeft() - params.leftMargin; final int right = child.getRight() + params.rightMargin; final int top = child.getTop() - params.topMargin - drawable.getIntrinsicHeight(); final int bottom = top + drawable.getIntrinsicHeight(); drawable.setBounds(left, top, right, bottom); drawable.draw(canvas);//from ww w . ja v a2 s . c o m }
From source file:Main.java
public static int getScrollY(AbsListView listView) { View c = listView.getChildAt(0); if (c == null) { return 0; }// ww w. j a va2 s . c o m int firstVisiblePosition = listView.getFirstVisiblePosition(); int scrollY = -(c.getTop()); listViewItemHeightCache.put(listView.getFirstVisiblePosition(), c.getHeight()); if (scrollY < 0) { scrollY = 0; } for (int i = 0; i < firstVisiblePosition; ++i) { if (listViewItemHeightCache.get(i) != null) { scrollY += listViewItemHeightCache.get(i); } } return scrollY; }
From source file:Main.java
/** * Helper for overriding {@link ViewGroup#gatherTransparentRegion} for views that are fully * opaque and have children extending beyond their bounds. If the transparent region * optimization is turned on (which is the case whenever the view hierarchy contains a * SurfaceView somewhere), the children might otherwise confuse the SurfaceFlinger. *///w w w.j ava 2 s . com public static void gatherTransparentRegionsForOpaqueView(View view, Region region) { view.getLocationInWindow(sLocationTmp); region.op(sLocationTmp[0], sLocationTmp[1], sLocationTmp[0] + view.getRight() - view.getLeft(), sLocationTmp[1] + view.getBottom() - view.getTop(), Region.Op.DIFFERENCE); }
From source file:Main.java
public static void addTouchFeedback(final ImageView view) { view.setOnTouchListener(new View.OnTouchListener() { private Rect rect; @Override//from w w w . j a v a 2 s . c o m public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { view.setColorFilter(Color.argb(50, 0, 0, 0)); rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); } if (event.getAction() == MotionEvent.ACTION_UP) { view.setColorFilter(Color.argb(0, 0, 0, 0)); } if (event.getAction() == MotionEvent.ACTION_MOVE) { if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { view.setColorFilter(Color.argb(0, 0, 0, 0)); } } return false; } }); }
From source file:Main.java
public static int getScrollY(AbsListView lv) { View c = lv.getChildAt(0); if (c == null) { return 0; }/*from w w w.j a v a 2 s . co m*/ int firstVisiblePosition = lv.getFirstVisiblePosition(); int scrollY = -(c.getTop()); // int scrollY = 0; sListViewItemHeights.put(lv.getFirstVisiblePosition(), c.getHeight()); // if(scrollY>0) // Log.d("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop())); // else // Log.i("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop())); if (scrollY < 0) scrollY = 0; for (int i = 0; i < firstVisiblePosition; ++i) { // Log.d("QuickReturnUtils", "getScrollY() : i - "+i); // Log.d("QuickReturnUtils", "getScrollY() : sListViewItemHeights.get(i) - "+sListViewItemHeights.get(i)); if (sListViewItemHeights.get(i) != null) // (this is a sanity check) scrollY += sListViewItemHeights.get(i); //add all heights of the views that are gone } // Log.d("QuickReturnUtils", "getScrollY() : scrollY - "+scrollY); return scrollY; }
From source file:Main.java
public static void drawTop(Canvas canvas, Drawable drawable, View child, ViewGroup.MarginLayoutParams params) { final int left = child.getLeft() - params.leftMargin - drawable.getIntrinsicWidth(); final int right = child.getRight() + params.rightMargin + drawable.getIntrinsicWidth(); final int top = child.getTop() - params.topMargin - drawable.getIntrinsicHeight(); final int bottom = top + drawable.getIntrinsicHeight(); drawable.setBounds(left, top, right, bottom); drawable.draw(canvas);/* ww w.j a v a 2s . com*/ }
From source file:com.czy.reecycleviewheader.ScrollableHelper.java
private static boolean isAdapterViewTop(AdapterView adapterView) { if (adapterView != null) { int firstVisiblePosition = adapterView.getFirstVisiblePosition(); View childAt = adapterView.getChildAt(0); if (childAt == null || (firstVisiblePosition == 0 && childAt != null && childAt.getTop() == 0)) { return true; }//from www. ja va 2s .com } return false; }
From source file:Main.java
/** * Return the position of {@code childView} relative to {@code rootView}. {@code childView} * must be a child of {@code rootView}. This returns the relative layout position, which does * not include translations./* w ww . j a v a2 s. c o m*/ * @param rootView The parent of {@code childView} to calculate the position relative to. * @param childView The {@link View} to calculate the position of. * @param outPosition The resulting position with the format [x, y]. */ public static void getRelativeLayoutPosition(View rootView, View childView, int[] outPosition) { assert outPosition.length == 2; outPosition[0] = 0; outPosition[1] = 0; while (childView != null && childView != rootView) { outPosition[0] += childView.getLeft(); outPosition[1] += childView.getTop(); childView = (View) childView.getParent(); } }