[go: up one dir, main page]

Skip to content

Arc pointer - simple customized progress bar in the form of an arch

License

Notifications You must be signed in to change notification settings

DVegasa/ArcPointer

Repository files navigation

ArcPointer

Simple customized progress bar in the form of an arch

Thumbnail

Demo

Demo gif animation

Quick start

Step 1

Gradle:

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

Maven:

<dependency>
  <groupId>io.github.dvegasa</groupId>
  <artifactId>arcpointer</artifactId>
  <version>1.0.2</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) Use setNotchesLengthRatio instead float getNotchLengthRatio() void setNotchLengthRatio(float notchLengthRatio);

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


notchStrokeWidth (float) Use setNotchesStrokeWidth instead 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) Use setNotchesColors instead int getColorNotches() void setColorNotches(int colorNotches)

Color of the notches


notchesColors (only Java) int[] getNotchesColors() void setNotchesColors(int color) void setNotchesColors(int[] colors)

Color of the notches.

Overload (int color) will set color for all notches

Overload (int[] colors) will set colors[i] color to notch[i]


notchesLengthRatio float[] getNotchesLengthRatio() void setNotchesLengthRatio(float ratio) void setNotchesLengthRatio(float[] ratios)

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

Overload (float ratio) will set length ratio for all notches.

Overload (float[] ratios) will set ratio[i] length ratio to notch[i]


notchesStrokeWidth float[] getNotchesStrokeWidth() void setNotchesStrokeWidth(float stroke) void setNotchesStrokeWidth(float[] stroke)

Notch width. Default value is 1.5f

Overload (float stroke) will set stroke width for all notches.

Overload (float[] stroke) will set stroke[i] stroke width to notch[i]


ChangeLog

1.0.2

27 June, 2018

  • Added customization of single notch:
    • Individual length
    • Individual color
    • Individual strokeWidth
  • Old methods for working with notches have become deprecated

Sample java class with 1.0.2 features

1.0.1

June, 2018

Bug fix

1.0.0

June, 2018

Release


LICENSE

   Copyright 2018 Eduard Khalturin

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Releases

No releases published

Packages

No packages published

Languages