Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomBar extends ProgressBar {
- Paint p = new Paint();
- int progress;
- public CustomBar(Context context) {
- super(context);
- p.setColor(Color.GREEN);
- }
- @Override
- protected synchronized void onDraw(Canvas canvas) {
- canvas.drawLine(0, 0, getWidth(), 0, p);
- canvas.drawLine(0, 0, 0, getHeight(), p);
- canvas.drawArc(new Rect(0, 0, getWidth(), getHeight()), 40, true, p);
- /**
- * Whatever drawing is needed for your Layout
- * But make sure you use relative lenghts and heights
- * So you can reuse your Widget.
- * Also use the Progress Variable to draw the filled part
- * corresponding to getMax()
- */
- }
- protected void onValueChanged(){
- /**
- * Update your progress Variable and draw again
- */
- progress = getProgress();
- this.invalidate();
- }
- @Override
- public synchronized void setMax(int max) {
- onValueChanged();
- super.setMax(max);
- }
- @Override
- public synchronized void setProgress(int progress) {
- onValueChanged();
- super.setProgress(progress);
- }
- @Override
- public synchronized void setSecondaryProgress(int secondaryProgress) {
- onValueChanged();
- super.setSecondaryProgress(secondaryProgress);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement