/** * set the visibility of indicator. * * @param visibility */ public void setIndicatorVisibility(IndicatorVisibility visibility) { if (visibility == IndicatorVisibility.Visible) { setVisibility(View.VISIBLE); } else { setVisibility(View.INVISIBLE); } resetDrawable(); }
/** * if you are using the default indicator , this method will help you to set the selected status * and the unselected status color. * * @param selectedColor * @param unselectedColor */ public void setDefaultIndicatorColor(int selectedColor, int unselectedColor) { if (mUserSetSelectedIndicatorResId == 0) { mSelectedGradientDrawable.setColor(selectedColor); } if (mUserSetUnSelectedIndicatorResId == 0) { mUnSelectedGradientDrawable.setColor(unselectedColor); } resetDrawable(); }
public void setDefaultUnselectedIndicatorSize(float width, float height, Unit unit) { if (mUserSetUnSelectedIndicatorResId == 0) { float w = width; float h = height; if (unit == Unit.DP) { w = pxFromDp(width); h = pxFromDp(height); } mUnSelectedGradientDrawable.setSize((int) w, (int) h); resetDrawable(); } }
/** * Set Indicator style. * * @param selected page selected drawable * @param unselected page unselected drawable */ public void setIndicatorStyleResource(int selected, int unselected) { mUserSetSelectedIndicatorResId = selected; mUserSetUnSelectedIndicatorResId = unselected; if (selected == 0) { mSelectedDrawable = mSelectedLayerDrawable; } else { mSelectedDrawable = mContext.getResources().getDrawable(mUserSetSelectedIndicatorResId); } if (unselected == 0) { mUnselectedDrawable = mUnSelectedLayerDrawable; } else { mUnselectedDrawable = mContext.getResources().getDrawable(mUserSetUnSelectedIndicatorResId); } resetDrawable(); }
/** * if you are using the default indicator, this method will help you to set the shape of * indicator, there are two kind of shapes you can set, oval and rect. * * @param shape */ public void setDefaultIndicatorShape(Shape shape) { if (mUserSetSelectedIndicatorResId == 0) { if (shape == Shape.Oval) { mSelectedGradientDrawable.setShape(GradientDrawable.OVAL); } else { mSelectedGradientDrawable.setShape(GradientDrawable.RECTANGLE); } } if (mUserSetUnSelectedIndicatorResId == 0) { if (shape == Shape.Oval) { mUnSelectedGradientDrawable.setShape(GradientDrawable.OVAL); } else { mUnSelectedGradientDrawable.setShape(GradientDrawable.RECTANGLE); } } resetDrawable(); }