-
-
Notifications
You must be signed in to change notification settings - Fork 326
Usage
if you want to add Right to Left language (like Arabic) just use app:sv_textRightToLeft="true"
attribute in XML, and setSpeedometerTextRightToLeft(true)
method in code.
look at the text in this image:
unit Text always attached to speed Text, you can change position using sv_speedTextPosition
Attribute, in your XML:
app:sv_speedTextPosition="TOP_LEFT"
in the Code:
speedometer.setSpeedTextPosition(Speedometer.Position.CENTER);
this image show you where could put speed-unit Text:
just for Speedometer family.
you can change the default start degree 135
and End Degree 405
easily.
in XML use app:sv_startDegree
and app:sv_endDegree
attributes :
<com.github.anastr.speedviewlib.SpeedView
android:id="@+id/speedView"
android:layout_width="300dp"
android:layout_height="wrap_content"
app:sv_startDegree="180"
app:sv_endDegree="360" />
in code use setStartDegree(int)
and setEndDegree(int)
methods :
speedView.setStartDegree(180);
speedView.setEndDegree(270);
just for Speedometer family.
now you can change the long of lowSpeed and mediumSpeed segments.
in XML use sv_lowSpeedPercent
and sv_mediumSpeedPercent
attributes :
<com.github.anastr.speedviewlib.SpeedView
android:id="@+id/speedView"
android:layout_width="300dp"
android:layout_height="wrap_content"
app:sv_lowSpeedPercent="50"
app:sv_mediumSpeedPercent="75" />
in code use setLowSpeedPercent(int)
and setMediumSpeedPercent(int)
methods :
speedView.setLowSpeedPercent(25);
speedView.setMediumSpeedPercent(75);
just for Speedometer family.
if you want to change indicator's position, or make semi-circular Gauge ...., you need to change sv_speedometerMode
, this image tell you what sv_speedometerMode
can do:
change speedometerMode
in XML:
app:sv_speedometerMode="TOP"
in the Code:
speedometer.setSpeedometerMode(Speedometer.Mode.TOP_LEFT);
just like AwesomeSpeedometer, since V 1.1.5 you can add labels at each tick points.
simply, you must specify the number of ticks and the library will calculate its values and positions.
in XML use sv_tickNumber
attribute like this:
<com.github.anastr.speedviewlib.SpeedView``
``android:id="@+id/speedometer"``
``android:layout_width="250dp"``
``android:layout_height="wrap_content"``
``android:layout_gravity="center_horizontal"``
``app:sv_tickNumber="6"/>
in your Code:
speedometer.setTickNumber(10);
by defult, AwesomeSpeedometer has TickNumber = 9.
you can add simple label to each tick in your speedometer, just use OnPrintTickLabel
interface.
for Example: we want to change tick 1000
to 1 km
.
speedometer.setOnPrintTickLabel(new OnPrintTickLabel() {
@Override
public String getTickLabel(int tickPosition, int tick) {
if(tick >= 1000)
return String.format(Locale.getDefault(), "%.1f Km", tick / 1000f);
return String.format(Locale.getDefault(), "%d M", tick);
}
});
this will draw n M
before 1000
value, and n Km
when value>=1000
.
you can add custom ticks at custom speed value, like so:
speedometer.setTicks(0, 10, 45, 100, ...);
Be Careful, custom ticks will be removed if you change Start and End Degree.
if you don't like its position you can change padding value easily using sv_tickPadding="10dp"
,
or speedometer.setTickPadding(15);
in java code.
We recommended to leave it at default value.
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.