Reputation: 735
I implemented the speedometer in my project by referring the code as found in the below link.
I need to animate the speedometer needle till i get the result from server, and once i got the result , i need to set the needle to proper value based on some calculation.
I am not understanding how to do it.
Please help me with some solution.
Upvotes: 0
Views: 5186
Reputation: 2766
private SpeedometerView speedometer;
// Customize SpeedometerView
speedometer = (SpeedometerView) v.findViewById(R.id.speedometer);
// Add label converter
speedometer.setLabelConverter(new SpeedometerView.LabelConverter() {
@Override
public String getLabelFor(double progress, double maxProgress) {
return String.valueOf((int) Math.round(progress));
}
});
// configure value range and ticks
speedometer.setMaxSpeed(300);
speedometer.setMajorTickStep(30);
speedometer.setMinorTicks(2);
// Configure value range colors
speedometer.addColoredRange(30, 140, Color.GREEN);
speedometer.addColoredRange(140, 180, Color.YELLOW);
speedometer.addColoredRange(180, 400, Color.RED);
Check the readme. Here you will find above code. And i think you need to look for how to change the needle.
And then call the public method SetSpeed(double speed) on the speedometer object. A simple look through the code in your link provides the answer.
Upvotes: 2