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

Related tags

UI/UX CircleDisplay
Overview

CircleDisplay

Android View for displaying and selecting (by touch) 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
  • Selecting / Choosing values with touch gestures (including callbacks)
  • Fully customizeable
  • Animated drawing (bar representig the value fills up animated)

alt tag

Usage

Simply copy the CircleDisplay.java file into your project. No annoying library imports, you ONLY need that single file.

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. You can either use Color.COLORNAME as a parameter or getColor(resid).
  • 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.
  • setDrawText(boolean enabled): If enabled, center text (containing value and unit) is drawn.
  • 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.
  • setUnit(String unit): Sets a unit that is displayed in the center of the view. E.g. "%" or "€" or whatever it is you want the circle-display to represent.
  • setStepSize(float stepsize): Sets the stepsize (minimum selection interval) of the circle display, default 1f. It is recommended to make this value not higher than 1/5 of the maximum selectable value, and not lower than 1/200 of the maximum selectable value. For example, if a maximum of 100 has been chosen, a stepsize between 0.5 and 20 is recommended.
  • setCustomText(String[] custom): Sets an array of custom Strings to be drawn instead of the actual value in the center of the CircleDisplay. If set to null, the custom text will be reset and the value will be drawn. Make sure the length of the array corresponds with the maximum number of steps (maxvalue / stepsize).

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.

Selecting values:

  • IMPORTANT for selecting values onTouch(): Make sure to call showValue(...) at least once before trying to select values by touching. This is needed to set a maximum value that can be chosen on touch. Calling showValue(0, 1000, false) before touching as an example will allow the user to choose a value between 0 and 1000, default 0.
  • setTouchEnabled(boolean enabled): Set this to true to allow touch-gestures / selecting.
  • setSelectionListener(SelectionListener l): Set a SelectionListener for callbacks when selecting values with touch-gestures.

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.setTouchEnabled(true);
    cd.setSelectionListener(this);
    cd.setUnit("%");
    cd.setStepSize(0.5f);
    // cd.setCustomText(...); // sets a custom array of text
    cd.showValue(75f, 100f, true);

License

Copyright 2014 Philipp Jahoda

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.

Comments
  • android.view.InflateException

    android.view.InflateException

    I have a few reports on this error:

    android.view.InflateException: Binary XML file line #97: Error inflating class com.philjay.circledisplay.CircleDisplay

    Caused by: java.lang.NoClassDefFoundError: android.animation.ObjectAnimator at com.philjay.circledisplay.CircleDisplay.init(CircleDisplay.java:128) at com.philjay.circledisplay.CircleDisplay.(CircleDisplay.java:102)

    I figured out that the problem has to do with the support library. it does not support the ObjectAnimator for API level 11 and below.

    I guess a workaround would be, only animate when API level is above 11.

    Is there maybe another fix for this?

    opened by alexandersch 2
  • CircleDisplay arc alignment goes out of bounds

    CircleDisplay arc alignment goes out of bounds

    The circle arc goes out of bounds whenever there is a heavy load operation performed (i.e.) in my case pulling data from the device internal storage database and displaying it in the circle.

    Under normal circumstances which doesn't involve heavy load operations the circle is displaying fine and the animation is smooth, but not otherwise.

    Is this related to performance issues? Please advice. (PFA - Screenshots)

    2015-05-13 18 21 33 2015-05-13 18 24 27

    opened by vikramezhil 1
  • Added feature to change arc color as the value progresses

    Added feature to change arc color as the value progresses

    if the maximum value is 100 and four colors are set in the int array in the order: red, orange, yellow, green. The arc color will be red between 0 - 25 will be red, 26 - 50 will be orange, 51 - 75 will be yellow and 76 - 100 will be green.

    opened by Dekola 0
  • Disappears in ScrollView

    Disappears in ScrollView

    I have an activity that shows a CircleDisplay beneath a chart. All works well when the layout is placed inside a LinearLayout. But when I place this LinearLayout inside a ScrollView, the CircleDisplay disappears (while the chart is still being shown correctly). Can this be a bug or am I missing something?

    opened by apatrone 1
  • Animate the Circle anti-clockwise

    Animate the Circle anti-clockwise

    There is not an option to change the animation from clockwise to anit-clokwise, I have to spent a couple of hours researching for implementing the anti-clockwise animation that I need to develop, so I think you can add this feature to your component and be custom in that way to. It very useful and works excellent.

    I did it changing this line mDrawAnimator = ObjectAnimator.ofFloat(this, "phase", mPhase,1.0f).setDuration(3000);

    for this: mDrawAnimator = ObjectAnimator.ofFloat(this, "phase", 1.0f,mPhase).setDuration(3000);

    I dont know if there a better way, but I hope it will help.

    opened by carlos-osejo 2
Releases(v1.0.2)
Owner
Philipp Jahoda
Passionate developer. Startup guy. Tech lover.
Philipp Jahoda
Android Library to implement simple touch/tap/swipe gestures

SimpleFingerGestures An android library to implement simple 1 or 2 finger gestures easily Example Library The library is inside the libSFG folder Samp

Arnav Gupta 315 Dec 21, 2022
An Android Widget for selecting items that rotate on a wheel.

Looking for maintainers I'm no longer active on this project but I'll still focus on fixing crashing issues and review any code changes etc. WheelView

Luke Deighton 888 Jan 3, 2023
An android custom view that displays a circle with a colored arc given a mark

MarkView An android custom view that displays a circle with a colored arc given a mark. Usage Add as a dependency compile 'com.github.xiprox.markv

İhsan Işık 200 Nov 25, 2022
A view to show bling bling stars when you touch it.

AndroidGlitterView A view to show bling bling stars when you touch it. Demo Dependency compile('com.liangfeizc:glitterview:1.0.0@aar') Attributes name

Fei Liang 177 Nov 10, 2022
A MaterialChipSetWidget is used to hold multiple chipsets 🤩 and each chipset has multiple values. 🔖

A MaterialChipSetWidget is used to hold multiple chipsets ?? and each chipset has multiple values. ??

Justin George 38 Sep 21, 2022
Simple and powerful library to emulate iOS's "3D Touch" preview functionality on Android.

Android 3D Touch - PeekView iOS uses 3D Touch as a way to "peek" into full content, such as emails, pictures, web searches, etc. While they have dedic

Luke Klinker 502 Dec 29, 2022
Stepper Touch for Android based on MaterialUp submission

Stepper-Touch For more updates on this and other open-source projects, follow me on twitter ?? here Stepper Touch for Android based on a Material Up s

Dion Segijn 667 Jan 1, 2023
TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

Tan Jun Rong 2.6k Jan 5, 2023
A beautiful Android custom View that works similar to a range or seekbar. With animations.

ValueBar A beautiful Android custom View that works similar to a range or seekbar. Selection by gesture. With animations. Supporting API level 11+. De

Philipp Jahoda 147 Nov 20, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Dec 30, 2022
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.

Dali Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live

Patrick Favre-Bulle 1k Dec 1, 2022
:balloon: A lightweight popup like tooltips, fully customizable with an arrow and animations.

Balloon ?? A lightweight popup like tooltips, fully customizable with arrow and animations. Including in your project Gradle Add below codes to your r

Jaewoong Eum 2.8k Jan 5, 2023
A material Switch with icon animations and color transitions

Material Animated Switch A material Switch with icon animations and color transitions Sample video: Youtube Material Animated Switch video Sample app:

Adrián Lomas 1.2k Dec 29, 2022
FloatingView can make the target view floating above the anchor view with cool animation

FloatingView FloatingView can make the target view floating above the anchor view with cool animation Links 中文版 README Blog about FloatingView demo.ap

UFreedom 1.8k Dec 27, 2022
用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View.

PathAnimView 用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View. 现已经找到图片->SVG->PATH的正确姿势, Now i have a pic.I have a view. Oh~,Path(A

张旭童 1.1k Oct 28, 2022
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Dec 29, 2022
View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

RippleView View that imitates Ripple Effect on click which was introduced in Android L. Usage For a working implementation, Have a look at the Sample

Muthuramakrishnan Viswanathan 1.2k Dec 30, 2022
Snake View is a simple and animated linear chart for Android.

Snake View Snake library is a simple and animation line chart for Android. Latest Version How to use Configuring your project dependencies Add the lib

Txus Ballesteros 339 Dec 14, 2022
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

Frederik Schweiger 1.5k Dec 30, 2022