- SDK 10 and and higher
Add the xml code:
<com.vitoksmile.library.view.controlview.ControlView
xmlns:cv="http://schemas.android.com/apk/res-auto"
android:id="@+id/controlView"
android:layout_width="match_parent"
android:layout_height="match_parent"
cv:colorArc="@color/colorAccent"
cv:colorBase="@color/colorPrimaryDark"
cv:colorValueNeed="@color/colorAccent"
cv:rangeMax="80"
cv:rangeMin="20"
cv:text="%"
cv:value="34"
cv:valueNeed="44" />
Add this to initialize the ControlView:
mControlView = (ControlView) findViewById(R.id.controlView);
Setters:
mControlView.setRange(0, 100);
mControlView.setValue(60);
mControlView.setValueNeed(75);
mControlView.setText("%");
mControlView.setColor(Color.BLUE);
mControlView.setColorArc(Color.GRAY);
mControlView.setColorValueNeed(Color.WHITE);
or use ControlViewBuilder:
new ControlViewBuilder()
.range(140, 360)
.value(179, 179)
.text("P")
.color(Color.YELLOW, Color.parseColor("#CCCC00"), Color.WHITE)
.build(mControlView);
ControlView.OnControlValueChangeListener
@Override
public void onControlValueChanged(float value) {
}