最终效果:

main.xml:
<com.fonsview.iseema.launcher.view.AodProgressBar
android:id="@+id/progress"
android:layout_width="886dp"
android:layout_height="16dp"
android:minHeight="8dp"
android:layout_marginStart="22dp"
app:AodProgressBar_background="@drawable/aod_progress_background"
app:AodProgressBar_indicator="@drawable/point_time"
app:AodProgressBar_progress="@drawable/aod_progress_drawable"
app:AodProgressBar_max="100"
app:AodProgressBar_value="40"/>
aod_progress_background:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="4dp" />
<solid android:color="#5cffffff" />
</shape>
aod_progress_drawable
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="4dp" />
<solid android:color="#c86464" />
</shape>
point_time:
AodProgressBar:
public class AodProgressBar extends View {
private Drawable backgroung;
private Drawable progress;
private Drawable indicator;
private int max, value;
public AodProgressBar(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public AodProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
}
public AodProgressBar(Context context) {
this(context, null, 0);
}
private void init(AttributeSet attrs) {
TypedArray ta = getContext().obtainStyledAttributes(attrs,
R.styleable.AodProgressBar);
try {
backgroung = ta
.getDrawable(R.styleable.AodProgressBar_AodProgressBar_background);
progress = ta
.getDrawable(R.styleable.AodProgressBar_AodProgressBar_progress);
indicator = ta
.getDrawable(R.styleable.AodProgressBar_AodProgressBar_indicator);
max = ta.getInt(R.styleable.AodProgressBar_AodProgressBar_max, 0);
value = ta.getInt(R.styleable.AodProgressBar_AodProgressBar_value,
0);
} finally {
ta.recycle();
}
}
@Override
protected void onDraw(Canvas canvas) {
Log.d(getClass().getSimpleName(), "------onDraw-------");
int top = (getMeasuredHeight() - getMinimumHeight()) / 2;
int bottom = top + getMinimumHeight();
int right = (int) (value * 1.0 / max * getMeasuredWidth());
if (backgroung != null) {
Log.d(getClass().getSimpleName(), "------background != null-------");
backgroung.setBounds(0, top, getMeasuredWidth(), bottom);
backgroung.draw(canvas);
}
if (progress != null) {
Log.d(getClass().getSimpleName(), "------progress != null-------");
progress.setBounds(0, top, right, bottom);
progress.draw(canvas);
}
if (indicator != null) {
Log.d(getClass().getSimpleName(), "------indicator != null-------");
indicator.setBounds(right - getMeasuredHeight() / 2, 0, right
+ getMeasuredHeight() / 2, getMeasuredHeight());
indicator.draw(canvas);
}
}
}