Giter Site home page Giter Site logo

plain-pie's Introduction

Add to your project build.gradle

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Add to your app module build.gradle

dependencies {
        compile 'com.github.zurche:plain-pie:v0.1.1'
}

Example Widget

Add the widget to your layout

<az.plainpie.PieView
    android:id="@+id/pieView"
    android:layout_width="200dp"
    android:layout_height="200dp"
    plainpie:inner_pie_padding="30"
    plainpie:percentage="75"
    plainpie:percentage_size="70"
    plainpie:inner_text_visibility="true"/>

Remember to add a namespace for the library in your layout:

xmlns:plainpie="http://schemas.android.com/apk/res-auto"

You can customize the widget from the layout file, or from the activity once you obtain a reference to it:

PieView pieView = (PieView) findViewById(R.id.pieView);
pieView.setPercentageBackgroundColor(getResources().getColor(R.color.customColor2));
pieView.setInnerText("A");

You can update any color of the widget:

PieView pieView = (PieView) findViewById(R.id.pieView);

// Change the color fill of the bar representing the current percentage
pieView.setPercentageBackgroundColor(getResources().getColor(R.color.customColor1));

// Change the color fill of the center of the widget
pieView.setCenterBackgroundColor(getResources().getColor(R.color.customColor21));

// Change the color fill of the background of the widget, by default is transparent
pieView.setMainBackgroundColor(getResources().getColor(R.color.customColor5));

// Change the color of the text of the widget
pieView.setTextColor(getResources().getColor(R.color.customColor12));

If required you can also change the area covered by the inner circle of the widget to change its appearence:

PieView pieView = (PieView) findViewById(R.id.pieView);

// Change the thickness of the percentage bar
pieView.setPieInnerPadding(50);

And finally update the text if you want the widget to represent other thing or even toggle the visibility of its center text:

PieView pieView = (PieView) findViewById(R.id.pieView);

// Update the visibility of the widget text
pieView.setInnerTextVisibility(View.VISIBLE);

// Change the text of the widget
pieView.setInnerText("A");

// Change the text size of the widget
pieView.setPercentageTextSize(35);
Without inner text With a label instead of a percentage
alt tag alt tag

License

Copyright 2016 Alejandro Zürcher

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.

plain-pie's People

Contributors

zurche avatar elkfrawy-df avatar

Watchers

Naseem Akhtar 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.