Android View for displaying values / percentages in a circle-shaped View, with animations.
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)
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 newPaint
object instead of the default one. UseCircleDisplay.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);