Skip to content

Android View for displaying and selecting values in a circle-shaped View, with animations and touch gestures.

Notifications You must be signed in to change notification settings

PhilJay/CircleDisplay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CircleDisplay

Android View for displaying values / percentages in a circle-shaped View, with animations.

Features

Core features:

  • Displaying values in a beautiful circle shaped View
  • Supports percentage and normal values
  • Fully customizeable
  • Animated drawing (bar representig the value fills up animated)

alt tag

Usage

Simply copy the CircleDisplay.java file into your project.

For using the CircleDisplay, define it in .xml:

    <com.philjay.circledisplay.CircleDisplay
        android:id="@+id/circleDisplay"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    CircleDisplay cd = (CircleDisplay) findViewById(R.id.circleDisplay);

or create it in code:

    CircleDisplay cd = new CircleDisplay(Context);

Style your CircleDisplay, and show values.

Styling methods:

  • setColor(int color): Use this method to set the color for the arc/bar that represents the value.
  • setStartAngle(float angle): Set the starting angle of your arc/bar. By default, it starts at the top of the view (270°).
  • setAnimDuration(int millis): Set the duration in milliseconds it takes to animate/build up the bar.
  • setTextSize(float size): Set the size of the text in the center of the view.
  • setValueWidthPercent(float percentFromTotalWidth): Set the width of the value bar/arc in percent of the circle radius.
  • setFormatDigits(int digits): Sets the number of digits to use for the value in the center of the view.
  • setDimAlpha(int alpha): Value between 0 and 255 indicating the alpha value used for the remainder of the value-arc.
  • setPaint(int which, Paint p): Sets a new Paint object instead of the default one. Use CircleDisplay.PAINT_TEXT for example to change the text paint used.

Showing stuff:

  • public void showValue(float toShow, float total, boolean animated): Shows the given value. A maximumvalue also needs to be provided. Set animated to true to animate the displaying of the value.
  • public void showPercentage(float percentage, boolean animated): Shows the given percentage value. Set animated to true to animate the displaying of the value.

Full example:

    CircleDisplay cd = (CircleDisplay) findViewById(R.id.circleDisplay);
    cd.setAnimDuration(3000);
    cd.setValueWidthPercent(55f);
    cd.setTextSize(36f);
    cd.setColor(Color.GREEN);
    cd.setDrawText(true);
    cd.setDrawInnerCircle(true);
    cd.setFormatDigits(1);
    cd.showPercentage(75f, true);

About

Android View for displaying and selecting values in a circle-shaped View, with animations and touch gestures.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages