/ Progress

Simple customized progress bar in the form of an arch

Simple customized progress bar in the form of an arch

ArcPointer

Simple customized progress bar in the form of an arch.

Demo

enter image description here

Quick start

Step 1

Gradle:

compile 'io.github.dvegasa:arcpointer:1.0.1'

Maven:

<dependency>
  <groupId>io.github.dvegasa</groupId>
  <artifactId>arcpointer</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>

Step 2

XML:

<io.github.dvegasa.arcpointer.ArcPointer
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:radius="150dp"
        android:padding="8dp"
        android:id="@+id/arcpointer"/>

Java:

        ArcPointer arcPointer = findViewById(R.id.arcpointer);
        arcPointer.setValue(0.5f);
        arcPointer.setNotches(9);
        [...]


android:layout_width and android:layout_height should be set "wrap_content". To specify the size of View, use the radius.

Documentation

Definitions


XML attributes and Java methods

radius (dp)
int getRadius()
void setRadius(int radius)

The radius of arc


value (float)
float getValue()
void setValue(float value)

The pointer positon. Value is a float between 0 and 1 (see image above for more understanding)

     0f = left border
   0.5f = mid of arc
     1f = right border

workAngle (int) [degrees]
int getWorkAngle()
void setWorkAngle(int workAngle)

The value of the angle of the arch in degrees


notches (Only Java)
float[] getNotches()
void setNotches(int n)
void setNotches (float[] notches)

The position of notches on the arch.

  • If you use (int n) overload, the n notches will be located evenly
  • If you use (float[] notches) overload, the notches will be located on the coordinates you specify

setNotches(new float[]{0.1f, 0.2f, 0.5f});

setNotches(3);
setValue(0.625f);


isAnimated (boolean)
boolean isAnimated()
void setAnimated(boolean animated)

If true, then the value change occurs with animation.


animationVelocity (int in XML)
long getAnimationVelocity()
void setAnimationVelocity(long animationVelocity)

Animation speed. The smaller, the faster. Default value is 1500L

{!} Calling setAnimationVelocity doesn't cause the redraw of View


lineLengthRatio (float)
float getLineLengthRatio()
void setLineLengthRatio(float lineLengthRatio)

Indicates the length of the line relative to the radius of the arc.

lineLength = radius * lineLengthRatio


lineStrokeWidth (float)
float getLineStrokeWidth()
void setLineStrokeWidth(float lineStrokeWidth)

Line width. Default value is 2f


markerLengthRatio (float)
float getMarkerLengthRatio()
void setMarkerLengthRatio(float markerLengthRatio)

Indicates the length of the marker relative to the length of line


markerStrokeWidth (float)
float getMarkerStrokeWidth()
void setMarkerStrokeWidth(float markerStrokeWidth)

Marker width. Default value is 3f


notchesLengthRatio (float)
float getNotchLengthRatio()
void setNotchLengthRatio(float notchLengthRatio);

Indicates the length of the notch relative to the radius of arc


notchStrokeWidth (float)
float getNotchStrokeWidth()
void setNotchStrokeWidth(float notchStrokeWidth)

Notch width. Default value is 1.5f


colorBackground (int)
int getColorBackground()
void setColorBackground(int colorBackground)

Color of the background


colorLine (int)
int getColorLine()
void setColorLine(int colorLine)

Color of the line


colorMarker (int)
int getColorMarker()
void setColorMarker(int colorMarker)

Color of the marker


colorNotches (int)
int getColorNotches()
void setColorNotches(int colorNotches)

Color of the notches

GitHub