androidx.viewpager.widget.PagerTitleStrip Java Examples
The following examples show how to use
androidx.viewpager.widget.PagerTitleStrip.
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: ViewPagerActions.java From android-test with Apache License 2.0 | 4 votes |
/** Clicks between two titles in a <code>ViewPager</code> title strip */ public static ViewAction clickBetweenTwoTitles(final String title1, final String title2) { return new GeneralClickAction( Tap.SINGLE, new CoordinatesProvider() { @Override public float[] calculateCoordinates(View view) { PagerTitleStrip pagerStrip = (PagerTitleStrip) view; // Get the screen position of the pager strip final int[] viewScreenPosition = new int[2]; pagerStrip.getLocationOnScreen(viewScreenPosition); // Get the left / right of the first title int title1Left = 0, title1Right = 0, title2Left = 0, title2Right = 0; final int childCount = pagerStrip.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = pagerStrip.getChildAt(i); if (child instanceof TextView) { final TextView textViewChild = (TextView) child; final CharSequence childText = textViewChild.getText(); if (title1.equals(childText)) { title1Left = textViewChild.getLeft(); title1Right = textViewChild.getRight(); } else if (title2.equals(childText)) { title2Left = textViewChild.getLeft(); title2Right = textViewChild.getRight(); } } } if (title1Right < title2Left) { // Title 1 is to the left of title 2 return new float[] { viewScreenPosition[0] + (title1Right + title2Left) / 2, viewScreenPosition[1] + pagerStrip.getHeight() / 2 }; } else { // The assumption here is that PagerTitleStrip prevents titles // from overlapping, so if we get here it means that title 1 // is to the right of title 2 return new float[] { viewScreenPosition[0] + (title2Right + title1Left) / 2, viewScreenPosition[1] + pagerStrip.getHeight() / 2 }; } } }, Press.FINGER, 0, 0); }
Example #2
Source File: HoodDebugPageView.java From under-the-hood with Apache License 2.0 | 2 votes |
/** * The tabs view. Use for customizing the view. * * @return tabs */ public PagerTitleStrip getTabs() { return tabs; }