Skip to content

Instantly share code, notes, and snippets.

@premacck
Last active August 22, 2018 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save premacck/9344f17da8e0a25712b1395991f0c5d5 to your computer and use it in GitHub Desktop.
Save premacck/9344f17da8e0a25712b1395991f0c5d5 to your computer and use it in GitHub Desktop.
Android progressBar in reverse direction.
// TODO: put package information here
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ProgressBar;
/**
*
* Created by Prem $ on 9/29/2017.
*/
public class FlippedProgressBar extends ProgressBar {
public FlippedProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public FlippedProgressBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FlippedProgressBar(Context context) {
super(context);
}
@Override
protected synchronized void onDraw(Canvas canvas) {
canvas.scale(-1f, 1f, super.getWidth() * 0.5f, super.getHeight() * 0.5f);
super.onDraw(canvas);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment