Coder Social home page Coder Social logo

circularcounter's Introduction

Circular Counter

Circular Counter is an Android Widget I needed to implement for an application I was developing. As it could be useful to more people, I tried to make it generic enough to share and be used by others.

The view shows a value in the center together with 3 bars that grow depending on the values received. Digging into the code you can easily increase or decrease the number of bars.

Android app on Google Play

Android Arsenal

Screenshot

Demo Screenshot

Usage

Add CircularCounter widget to your layout. Configure the view customization elements using styleable attributes or/and programatically. This is a basic example, explore the code to get to know it in detail.

    <com.db.circularcounter.CircularCounter
        xmlns:counter="http://schemas.android.com/apk/res-auto"
        android:id="@+id/counter"
        android:layout_width="300dp"
        android:layout_height="300dp"
        counter:range="60"
        counter:textSize="100sp"
        counter:textColor="#ffffff"
        counter:metricSize="20sp"
        counter:metricText="metric"
    />
    //First Bar
    counter.setFirstWidth(getResources().getDimension(R.dimen.first))
    counter.setFirstColor(Color.parseColor(colors[0]))

    //Second Bar
    counter.setSecondWidth(getResources().getDimension(R.dimen.second))
    counter.setSecondColor(Color.parseColor(colors[1]))

    //Third Bar
    counter.setThirdWidth(getResources().getDimension(R.dimen.third))
    counter.setThirdColor(Color.parseColor(colors[2]))
            
    counter.setBackgroundColor(Color.parseColor(colors[3]));

To pass values to the view use setValues(value1, value2, value3). First value will be the one shown in text.

circularcounter's People

Contributors

diogobernardino avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.