Skip to content

Methods and Attributes

Anas Altair edited this page Dec 14, 2016 · 2 revisions

methods for All Speedometers :

speedTo(int speed)

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);

speedTo(int speed, long moveDuration)

same speedTo(int) with Duration in millisecond.

speedometer.speedTo(44, 3000);

speedPercentTo(int percent)

move indicator to percent value.
percent should be between [0,100].

// to move the indicator to half.
speedometer.speedPercentTo(50);

setMaxSpeed(int maxSpeed)

change max speed.
default : 100.

speedometer.setMaxSpeed(320);

stop()

stop indicator in its degree.

speedometer.stop();

realSpeedTo(int speed)

to make speedometer some real.
when speed up : speed value well increase slowly.
when slow down : speed value will decrease rapidly.

speedometer.realSpeedTo(80);

speedUp()

it use realSpeedTo(MAX Speed).

speedometer.speedUp();

slowDown()

it use realSpeedTo(0).

speedometer.slowDown();

setWithTremble(boolean withTremble)

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);

setTrembleDegree (float trembleDegree)

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);

setTrembleDuration (int trembleDuration)

tremble Animation duration in millisecond, should be > 0 and <= 6000, else well be ignore.
default : 1000 millisecond.

speedometer.setTrembleDuration(2000);

setTrembleData (float trembleDegree, int trembleDuration)

to set trembleDegree and trembleDuration at the same time.

speedometer.setTrembleDuration(2, 2500);

getCorrectSpeed()

what is correct speed now.
It will give different results if withTremble is running.

float speed = speedometer.getCorrectSpeed();
Log.e("Correct Speed is", speed + "");

getPercentSpeed()

get speed as percent, between [0,100].

float speed = speedometer.getPercentSpeed();
Log.e("Percent Speed is", speed + "");

Attributes

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"