Android知识点和文章分享Android开发Android开发经验谈

一款自定义View:PercentProgressBar

2017-07-30  本文已影响0人  Ro0kieY

PercentProgressBar

The idea of PercentProgressBar came from here.

I decided to do this because it's an inspired UI design and i want to learn about custom view by this, even though it's simple.


Demo

imgimg

Download Demo


Usage

Step 1. Add the JitPack repository to your build file

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

Step 2. Add the dependency

dependencies {
        compile 'com.github.Ro0kieY:PercentProgressBar:0.9'
}

use it in your code

<com.ro0kiey.percentprogressbar.PercentProgressBar
    android:id="@+id/percent_progress_bar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:progress_bar_style="circular"/>

use progress_bar_style attribute to decide whether the bar is circular or horizontal.


Attributes

There are several attributes you can set:

The outer border:

The progress bar:

The text area:

The little circle:

the default attributes are:

<com.ro0kiey.percentprogressbar.PercentProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    app:outer_width="15dp"
    app:outer_color="#FFFFFF"
    app:outer_alpha="50"

    app:progress_bar_width="10dp"
    app:progress_bar_color="#5DD4CD"
    app:progress_bar_alpha="255"
    app:current_progress="0"
    app:max_progress="100"

    app:text_size="15sp"
    app:text_color="#FFFFFF"
    app:text_alpha="255"

    app:little_circle_color="#FFFFFF"
    app:little_circle_alpha="255" />

Public Methods

About me

I'm a engineer, but try to be a coder. I'm now learning Android development by myself.

If you have job oppoturnity, please email me.

上一篇下一篇

猜你喜欢

热点阅读