Ejemplo n.º 1
0
        public static bool IsChildInCenterY(RecyclerView recyclerView, View view)
        {
            int childCount = recyclerView.ChildCount;

            int[] lvLocationOnScreen = new int[2];
            int[] vLocationOnScreen  = new int[2];
            recyclerView.GetLocationOnScreen(lvLocationOnScreen);
            int middleY = lvLocationOnScreen[1] + recyclerView.Height / 2;

            if (childCount > 0)
            {
                view.GetLocationOnScreen(vLocationOnScreen);
                if (vLocationOnScreen[1] <= middleY && vLocationOnScreen[1] + view.Height >= middleY)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static bool IsChildInCenterX(RecyclerView recyclerView, View view)
        {
            int childCount = recyclerView.ChildCount;

            int[] lvLocationOnScreen = new int[2];
            int[] vLocationOnScreen  = new int[2];
            recyclerView.GetLocationOnScreen(lvLocationOnScreen);
            int middleX = lvLocationOnScreen[0] + recyclerView.Width / 2;

            if (childCount > 0)
            {
                view.GetLocationOnScreen(vLocationOnScreen);
                if (vLocationOnScreen[0] <= middleX && vLocationOnScreen[0] + view.Width >= middleX)
                {
                    return(true);
                }
            }
            return(false);
        }