Android自定义进度条
借助Andorid5.0提供的cardView切圆角,使用切图叠加的形式,调整View的scrollY完成一个炫酷的进度条;
进度条代码
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
/**
* Created by Administrator on 2017/9/29 0029.
*/
public class EnergyView extends RelativeLayout {
public static final String TAG = EnergyView.class.getSimpleName();
private ImageView img;
private View empty;
public EnergyView(Context context) {
this(context,null);
}
public EnergyView(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public EnergyView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
LayoutInflater in = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
in.inflate(R.layout.energy_view, this, true);
img = (ImageView) findViewById(R.id.img);
empty = findViewById(R.id.img_empty);
}
private float currentProgress = 0;