Issue
I'm working on a custom Android widget that will both positive and negative values as a bar. Since I'm going with a stock look, I thought I'd extend the ProgressBar class and use that as a base for my widget. However, I can't seem to find a way to programatically get a handle on the bar itself (as opposed to the entire drawable or the entire canvas) so that I can set the start of the Rect to the middle of the bar.
The effect I'd like to achieve is something like this (showing a negative value, if it were positive obviously it would be going the other way).

I've already overridden the progress setters to check if we've stored a negative value:
private boolean isNegative;
@Override
public void setProgress(final int progress) {
isNegative = progress < 0;
super.setProgress(Math.min(Math.abs(progress), this.getMax()));
}
@Override
public int getProgress() {
return (isNegative ? -1 : 1) * super.getProgress();
}
It's really just drawing the thing that I can't figure out. This only needs to target the latest API (19 as of this post).
Solution
Maybe it's too late to answer, but you could use two ProgressBar, set the first to be right to left with progressBar.setRotation(180); and then treat them independently, updating both when your status changes.
Answered By - kauron
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.