Skip to content

Indicators

Anas Altair edited this page Dec 28, 2019 · 10 revisions

Work with Indicators

since version 1.1.2 you can change the indicator, or remove it for All Speedometers.

just for Speedometer family.

in XML

add app:sv_indicator="" attribute (enum value) to your speedometer to change the indicator. like so:

<com.github.anastr.speedviewlib.SpeedView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        app:sv_indicator="TriangleIndicator" />

in Code

speedometer.setIndicator(Indicator.Indicators.SpindleIndicator)

All indicators

indicator Name Screenshot indicator Name Screenshot
NoIndicator NormalIndicator
TriangleIndicator NormalSmallIndicator
SpindleIndicator LineIndicator
HalfLineIndicator QuarterLineIndicator
KiteIndicator NeedleIndicator

Width and Color

indicator is Observable by its Speedometer, so.. one indicator must be added to one speedometer.
and so, to change width or color you can call immediately speedometer.indicator.width = 20f or speedometer.indicator.color = Color.BLUE without tack care of invalidate the SpeedView, because it's observing any change to indicator and do auto invalidate.
also you can change width and color in XML:

sv_indicatorColor=""
sv_indicatorWidth=""

ImageIndicator

you can add custom indicator, just add indicator's image to your drawable folder, and use ImageIndicator Object.
must set the center of indicator in the center of image, and the indicator towards the top,just like this one:

image indicator

to create object you cans use: ImageIndicator(context: Context, resource: Int) eysly, but we Recommend to use ImageIndicator(context: Context, resource: Int, width: Int, height: Int) to add custom width and height for indicator.

val imageIndicator = ImageIndicator(getApplicationContext(), R.drawable.image_indicator1)

speedometer.indicator = imageIndicator