作用:自定义小控件
效果图:
style文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="AbSlidingButtonStyle">
<attr name="btn_bottom" format="integer|reference" />
<attr name="btn_frame" format="integer|reference" />
<attr name="btn_mask" format="integer|reference" />
<attr name="btn_unpressed" format="integer|reference" />
<attr name="btn_pressed" format="integer|reference" />
</declare-styleable>
<declare-styleable name="BaseDoT">
<attr name="circleColor" format="color|reference" />
</declare-styleable>
<declare-styleable name="BaseDoTView">
<attr name="slideCount" format="integer|reference" />
<attr name="selectPosition" format="integer|reference" />
<attr name="selectedIndicatorColor" format="color|reference" />
<attr name="unselectedIndicatorColor" format="color|reference" />
<attr name="circleRadius" format="dimension|reference" />
</declare-styleable>
<declare-styleable name="BaseTopBackCenterHeader">
<attr name="headerTitle" format="reference|string" />
<attr name="headerTitleColor" format="color|reference" />
<attr name="headerShowLeft" format="boolean" />
<attr name="headerLeftTitle" format="reference|string" />
</declare-styleable>
</resources>
Dot(自定义小圆点)文件
public class Dot extends ImageView {
/**
* 放大放大倍数
*/
public static final float SCALE = 1.0f;
/**
* 透明度
*/
public static final int ALPHA = 255;
private float[] scaleFloats = new float[]{SCALE, SCALE, SCALE};
private int[] alphas = new int[]{ALPHA, ALPHA, ALPHA,};
public Dot(Context context) {
this(context, null);
}
public Dot(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
/**
* 小圆初始化设置
*
* @param context
* @param attrs
*/
private void init(Context context, AttributeSet attrs) {
paint = new Paint();
paint.setAntiAlias(true);// 设置画笔