Java Code Examples for android.support.v7.widget.RecyclerView#getLocationOnScreen()
The following examples show how to use
android.support.v7.widget.RecyclerView#getLocationOnScreen() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CircularUtils.java From CircularViewPager with MIT License | 6 votes |
/** * @param recyclerView * @param view * @return */ public static boolean isChildInCenterX(@NonNull RecyclerView recyclerView, @NonNull View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleX = lvLocationOnScreen[0] + recyclerView.getWidth() / 2; if (childCount > 0) { int[] vLocationOnScreen = new int[2]; view.getLocationOnScreen(vLocationOnScreen); int width = view.getWidth(); if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + width >= middleX) { return true; } } return false; }
Example 2
Source File: CircularUtils.java From CircularViewPager with MIT License | 6 votes |
/** * @param recyclerView * @param view * @return */ public static boolean isChildInCenterX(@NonNull RecyclerView recyclerView, @NonNull View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleX = lvLocationOnScreen[0] + recyclerView.getWidth() / 2; if (childCount > 0) { int[] vLocationOnScreen = new int[2]; view.getLocationOnScreen(vLocationOnScreen); int width = view.getWidth(); if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + width >= middleX) { return true; } } return false; }
Example 3
Source File: ItemDragHelper.java From MultiItem with Apache License 2.0 | 6 votes |
/** * 获取当前点击的位置在RecyclerView内部的坐标 (Y坐标范围0+padding到height-padding)? */ private float[] getInsideLocation(RecyclerView recyclerView, float touchRawX, float touchRawY) { float[] result = new float[2]; int[] location = new int[2]; recyclerView.getLocationOnScreen(location); result[0] = touchRawX - location[0]; result[1] = touchRawY - location[1]; // System.out.println("getInsideLocation:" + result[0] + "-" + result[1] + "==" + "X:" + touchRawX + "Y:" + touchRawY); result[0] = result[0] / dragListener.getScale(); result[1] = result[1] / dragListener.getScale(); int minY = recyclerView.getPaddingTop(); int maxY = recyclerView.getHeight() - recyclerView.getPaddingBottom(); result[1] = Math.min(Math.max(result[1], minY), maxY); return result; }
Example 4
Source File: ChannelFragmentAdapter.java From letv with Apache License 2.0 | 6 votes |
private ImageView addMirrorView(ViewGroup parent, RecyclerView recyclerView, View view) { view.destroyDrawingCache(); view.setDrawingCacheEnabled(true); ImageView mirrorView = new ImageView(recyclerView.getContext()); Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); mirrorView.setImageBitmap(bitmap); view.setDrawingCacheEnabled(false); int[] locations = new int[2]; view.getLocationOnScreen(locations); int[] parenLocations = new int[2]; recyclerView.getLocationOnScreen(parenLocations); LayoutParams params = new LayoutParams(bitmap.getWidth(), bitmap.getHeight()); params.setMargins(locations[0], (locations[1] - parenLocations[1]) + UIsUtils.dipToPx(44.0f), 0, 0); parent.addView(mirrorView, params); return mirrorView; }
Example 5
Source File: ChannelAdapter.java From fingerpoetry-android with Apache License 2.0 | 6 votes |
/** * 添加需要移动的 镜像View */ private ImageView addMirrorView(ViewGroup parent, RecyclerView recyclerView, View view) { /** * 我们要获取cache首先要通过setDrawingCacheEnable方法开启cache,然后再调用getDrawingCache方法就可以获得view的cache图片了。 buildDrawingCache方法可以不用调用,因为调用getDrawingCache方法时,若果cache没有建立,系统会自动调用buildDrawingCache方法生成cache。 若想更新cache, 必须要调用destoryDrawingCache方法把旧的cache销毁,才能建立新的。 当调用setDrawingCacheEnabled方法设置为false, 系统也会自动把原来的cache销毁。 */ view.destroyDrawingCache(); view.setDrawingCacheEnabled(true); final ImageView mirrorView = new ImageView(recyclerView.getContext()); Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); mirrorView.setImageBitmap(bitmap); view.setDrawingCacheEnabled(false); int[] locations = new int[2]; view.getLocationOnScreen(locations); int[] parenLocations = new int[2]; recyclerView.getLocationOnScreen(parenLocations); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(bitmap.getWidth(), bitmap.getHeight()); params.setMargins(locations[0], locations[1] - parenLocations[1], 0, 0); parent.addView(mirrorView, params); return mirrorView; }
Example 6
Source File: NewsChannelAdapter.java From Toutiao with Apache License 2.0 | 6 votes |
/** * 添加需要移动的 镜像View */ private ImageView addMirrorView(ViewGroup parent, RecyclerView recyclerView, View view) { /** * 我们要获取cache首先要通过setDrawingCacheEnable方法开启cache,然后再调用getDrawingCache方法就可以获得view的cache图片了。 buildDrawingCache方法可以不用调用,因为调用getDrawingCache方法时,若果cache没有建立,系统会自动调用buildDrawingCache方法生成cache。 若想更新cache, 必须要调用destoryDrawingCache方法把旧的cache销毁,才能建立新的。 当调用setDrawingCacheEnabled方法设置为false, 系统也会自动把原来的cache销毁。 */ view.destroyDrawingCache(); view.setDrawingCacheEnabled(true); final ImageView mirrorView = new ImageView(recyclerView.getContext()); Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); mirrorView.setImageBitmap(bitmap); view.setDrawingCacheEnabled(false); int[] locations = new int[2]; view.getLocationOnScreen(locations); int[] parenLocations = new int[2]; recyclerView.getLocationOnScreen(parenLocations); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(bitmap.getWidth(), bitmap.getHeight()); params.setMargins(locations[0], locations[1] - parenLocations[1], 0, 0); parent.addView(mirrorView, params); return mirrorView; }
Example 7
Source File: ViewUtils.java From oneHookLibraryAndroid with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterY(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleY = lvLocationOnScreen[1] + recyclerView.getHeight() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.getHeight() >= middleY) { return true; } } return false; }
Example 8
Source File: RecyclerviewUtils.java From timecat with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterX(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleX = lvLocationOnScreen[0] + recyclerView.getWidth() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + view.getWidth() >= middleX) { return true; } } return false; }
Example 9
Source File: ViewUtils.java From oneHookLibraryAndroid with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterX(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleX = lvLocationOnScreen[0] + recyclerView.getWidth() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + view.getWidth() >= middleX) { return true; } } return false; }
Example 10
Source File: ViewUtils.java From RecyclerViewPager with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterY(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleY = lvLocationOnScreen[1] + recyclerView.getHeight() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.getHeight() >= middleY) { return true; } } return false; }
Example 11
Source File: ViewUtils.java From RecyclerViewPager with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterX(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleX = lvLocationOnScreen[0] + recyclerView.getWidth() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + view.getWidth() >= middleX) { return true; } } return false; }
Example 12
Source File: ViewUtils.java From MultiView with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterY(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] rvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(rvLocationOnScreen); int middleY = (int) (rvLocationOnScreen[1] + recyclerView.getHeight() * recyclerView.getScaleY() / 2); if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.getHeight() * view.getScaleY() >= middleY) { return true; } } return false; }
Example 13
Source File: ViewUtils.java From MultiView with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterX(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleX = (int) (lvLocationOnScreen[0] + recyclerView.getWidth() * recyclerView.getScaleX() / 2); if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + view.getWidth() * view.getScaleX() >= middleX) { return true; } } return false; }
Example 14
Source File: CircularUtils.java From CircularViewPager with MIT License | 5 votes |
/** * @param recyclerView * @param view * @return */ public static boolean isChildInCenterY(@NonNull RecyclerView recyclerView, @NonNull View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleY = lvLocationOnScreen[1] + recyclerView.getHeight() / 2; if (childCount > 0) { int[] vLocationOnScreen = new int[2]; view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.getHeight() >= middleY) { return true; } } return false; }
Example 15
Source File: CircularUtils.java From CircularViewPager with MIT License | 5 votes |
/** * @param recyclerView * @param view * @return */ public static boolean isChildInCenterY(@NonNull RecyclerView recyclerView, @NonNull View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleY = lvLocationOnScreen[1] + recyclerView.getHeight() / 2; if (childCount > 0) { int[] vLocationOnScreen = new int[2]; view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.getHeight() >= middleY) { return true; } } return false; }
Example 16
Source File: RecyclerviewUtils.java From DragBoardView with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterY(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleY = lvLocationOnScreen[1] + recyclerView.getHeight() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.getHeight() >= middleY) { return true; } } return false; }
Example 17
Source File: RecyclerviewUtils.java From DragBoardView with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterX(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleX = lvLocationOnScreen[0] + recyclerView.getWidth() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + view.getWidth() >= middleX) { return true; } } return false; }
Example 18
Source File: RecyclerviewUtils.java From timecat with Apache License 2.0 | 5 votes |
public static boolean isChildInCenterY(RecyclerView recyclerView, View view) { int childCount = recyclerView.getChildCount(); int[] lvLocationOnScreen = new int[2]; int[] vLocationOnScreen = new int[2]; recyclerView.getLocationOnScreen(lvLocationOnScreen); int middleY = lvLocationOnScreen[1] + recyclerView.getHeight() / 2; if (childCount > 0) { view.getLocationOnScreen(vLocationOnScreen); if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.getHeight() >= middleY) { return true; } } return false; }