22 | * To use the component, simply add it to your view hierarchy. Then in your 23 | * {@link android.app.Activity} or {@link android.support.v4.app.Fragment} call 24 | * {@link #setViewPager(ViewPager)} providing it the ViewPager this layout is being used for. 25 | *
26 | * The colors can be customized in two ways. The first and simplest is to provide an array of colors 27 | * via {@link #setSelectedIndicatorColors(int...)}. The 28 | * alternative is via the {@link TabColorizer} interface which provides you complete control over 29 | * which color is used for any individual position. 30 | *
31 | * The views used as tabs can be customized by calling {@link #setCustomTabView(int, int)},
32 | * providing the layout ID of your custom layout.
33 | */
34 | public class SlidingTabLayout extends HorizontalScrollView {
35 | /**
36 | * Allows complete control over the colors drawn in the tab layout. Set with
37 | * {@link #setCustomTabColorizer(TabColorizer)}.
38 | */
39 | public interface TabColorizer {
40 |
41 | /**
42 | * @return return the color of the indicator used when {@code position} is selected.
43 | */
44 | int getIndicatorColor(int position);
45 |
46 | }
47 |
48 | private static final int TITLE_OFFSET_DIPS = 24;
49 | private static final int TAB_VIEW_PADDING_DIPS = 16;
50 | private static final int TAB_VIEW_TEXT_SIZE_SP = 12;
51 |
52 | private int mTitleOffset;
53 |
54 | private int mTabViewLayoutId;
55 | private int mTabViewTextViewId;
56 | private boolean mDistributeEvenly;
57 |
58 | private ViewPager mViewPager;
59 | private SparseArray