I have a circular progress bar, what i want to do is to use it to measure speed, something like a car speedometer, but i don't know how to do thisSOMETHING LIKE THIS. Or if it is possible using a circular progress bar. So what i was doing was store the speed in a variable and the use progressbar.setProgress to get the speed. But it's not working because i think is not right, So Any advice or suggestion is welcome.
MainActivity:
public class MainActivity extends AppCompatActivity {
ProgressBar mprogressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mprogressBar = (ProgressBar) findViewById(R.id.circular_progress_bar);
ObjectAnimator anim = ObjectAnimator.ofInt(mprogressBar, "progress", (int)speeeeed, 25);
Log.e("valor de speed", Double.toString(speeeeed));
mprogressBar.setProgress((int) speeeeed);
anim.setDuration(15000);
anim.setInterpolator(new DecelerateInterpolator());
anim.start();
}
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
float Real =(location.getSpeed()*3600/1000);
String convertedSpeed = String.format("%.2f",Real);
TVKm.setText(convertedSpeed);
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
}
public void onProviderEnabled(String provider) {
}
public void onProviderDisabled(String provider) {
}
};
circularprogressbar.xml
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="2.3"
android:shape="ring"
android:thickness="10dp"
android:useLevel="true">
<solid android:color="#e6c009" />
activity_main.xml
<ProgressBar
android:id="@+id/circular_progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="30dp"
android:indeterminate="false"
android:max="48"
android:progress="1"
android:progressDrawable="@drawable/circular_progressbar" />