-
-
Notifications
You must be signed in to change notification settings - Fork 324
Methods and Attributes
methods for All Speedometers :
- speedTo(int speed)
- speedTo(int speed, long moveDuration)
- speedPercentTo(int percent)
- setMaxSpeed(int maxSpeed)
- stop()
- realSpeedTo(int speed)
- speedUp()
- slowDown()
- setWithTremble(boolean withTremble)
- setTrembleDegree (float trembleDegree)
- setTrembleDuration (int trembleDuration)
- setTrembleData (float trembleDegree, int trembleDuration)
- getCorrectSpeed()
- getPercentSpeed()
The base method to move indicator to a specific Speed with default Duration = 2000 ms.
speed should be between [0, MAX Speed]
.
speedometer.speedTo(44);
same speedTo(int)
with Duration in millisecond.
speedometer.speedTo(44, 3000);
move indicator to percent value.
percent should be between [0,100]
.
// to move the indicator to half.
speedometer.speedPercentTo(50);
change max speed.
default : 100.
speedometer.setMaxSpeed(320);
stop indicator in its degree.
speedometer.stop();
to make speedometer some real.
when speed up : speed value well increase slowly.
when slow down : speed value will decrease rapidly.
speedometer.realSpeedTo(80);
it use realSpeedTo(MAX Speed).
speedometer.speedUp();
it use realSpeedTo(0).
speedometer.slowDown();
if true : the indicator automatically will be increases and decreases trembleDegree
degree around last speed you set, to add some reality to speedometer.
if false : nothing will do.
speedometer.setWithTremble(false);
a degree to increases and decreases the indicator around correct speed.
it should be between ]0, 10]
, else well throw IllegalArgumentException
.
default : 4.
speedometer.setTrembleDegree(3);
tremble Animation duration in millisecond, should be > 0 and <= 6000
, else well be ignore.
default : 1000 millisecond.
speedometer.setTrembleDuration(2000);
to set trembleDegree
and trembleDuration
at the same time.
speedometer.setTrembleDuration(2, 2500);
what is correct speed now.
It will give different results if withTremble
is running.
float speed = speedometer.getCorrectSpeed();
Log.e("Correct Speed is", speed + "");
get speed as percent, between [0,100]
.
float speed = speedometer.getPercentSpeed();
Log.e("Percent Speed is", speed + "");
you can change everything from xml
.
see this General Attributes for most Speedometers :
app:unit="m/s" <!-- def : Km/h -->
app:maxSpeed="220" <!-- def : 100 -->
app:minSpeed="-50" <!-- def : 0 -->
app:withTremble="false" <!-- def : true -->
app:backgroundCircleColor="#f00"
app:speedometerWidth="35dp" <!-- def : 30dp -->
app:indicatorColor="#2b38e6"
app:centerCircleColor="#b2f941ff"
app:lowSpeedColor="#58ed21"
app:mediumSpeedColor="#edd029"
app:highSpeedColor="#ec2f33"
app:markColor="#99000000"
app:textColor="#e23900"
app:speedTextColor="#000000"
app="unitTextSize"="12sp"
app="trembleDegree"="8"
app="trembleDuration"="2000"
app="startDegree"="180"
app="endDegree"="360"
app="lowSpeedPercent"="25"
app="mediumSpeedPercent"="75"
app="speedometerTextRightToLeft"="true"
if you have any idea, image, template please open new issue and give me the image , and i well try to add it to the Library, it must be possible to drawn, if you like this library you can support it.