Giter VIP home page Giter VIP logo

circle-progress-view's Introduction

CircleView

An animated circle view. Can be used in 'value mode' or 'spinning mode'. Nice transitions between spinning and value. Can be used as a loading indicator and to show progress or values in a circular manner. In seek mode, it can also be used to set a value.

MainImage

Try it out here.

Fully animated:

animation demo

  • Animated set value.
  • Spinning mode.
  • Transition from spinning mode to value mode.

Fully customizable:

CircleParts

All parts come with a customizable color and thickness. Set the size of a part to 0 to hide it.

Text sizes

Per default, the texts size is automatically calculated to fit in the circle.

Colors

The spin bar color can consist of a single color or a gradient from up to 4 colors.

Gradient colors.

Block Mode

  • Via XML
CircleProgressView:cpv_blockCount="18"
CircleProgressView:cpv_blockScale="0.9"

Seek Mode

Set value on touch input. Enable it:

  • Via Code:
circleview.setSeekModeEnabled(true);
  • Via XML:
CircleProgressView:cpv_seekMode="true"

For more examples take a look at the example app.

Add it to your project:

Get the latest release from https://jitpack.io/#jakob-grabner/Circle-Progress-View

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

dependencies {
	// ...
        implementation 'com.github.jakob-grabner:Circle-Progress-View:1.4'
}

JavaDoc

Get it here.

circle-progress-view's People

Contributors

6bangs avatar amartinz avatar bradmartin avatar jakob-grabner avatar ravidsrk avatar rtjag avatar sg57 avatar suomi35 avatar timoshenkoav avatar tobias-ma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circle-progress-view's Issues

Show decimals number ?

Hello, this is a great library. I like it. Thanks for your hard work. Can I ask how to show decimals number ?
Ex: I set max value to "10" and I want to show current value is "6.8". I have tried, but it show "68" not "6.8".

i can't change color of text

Hi

i try to change color of text using:
setUnitColor & setTextColor
but i can't

what happened that Text color is same color of bar

note: i can change size of text using:
setTextSize

Regards

Unable to compile via Gradle

Hi, I tried following:

compile 'com.github.jakob-grabner:Circle-Progress-View:a9ac80c39b'

OR

compile 'com.github.jakob-grabner:Circle-Progress-View:1.1'

But, it comes error says:

Error:(45, 13) Failed to resolve: com.github.jakob-grabner:Circle-Progress-View:a9ac80c39b

May you suggest the correct way to install this library through gradle?

when i polling data from server refresh view in RecyclerView.Adapter, The view always twinkling

I always get same data from server. but when i refresh,the circle-progress-view will change from 0 to the value I set. why ?
this is code

  @Override
    public void onBindViewHolder(StoveHolder holder, int position) {
        DeviceEntity stoveItem = lists.get(position);
        if(stoveItem != null) {
            holder.stoveDevice.setBackgroundResource(StatusMap.statusAndView.get(stoveItem.getStatus().name()));
            holder.stoveNum.setText(stoveItem.getAssetsCode());
            holder.runState.setText(stoveItem.getStatus().name());
            holder.runStateBlock.setBackgroundResource(StatusMap.statusAndView.get(stoveItem.getStatus().name()));
            holder.timeLeft.setText(stoveItem.getResidualTime());
            holder.firstSetting.setText(stoveItem.getTemperature());

           // circle-progress-view  set value
            holder.firstActual.setValue(Float.parseFloat(stoveItem.getTemperature1()));


            holder.secondSetting.setText(stoveItem.getTemperature());
            holder.secondActual.setValue(Float.parseFloat(stoveItem.getTemperature2()));
            holder.thirdSetting.setText(stoveItem.getHumidity());
            holder.thirdActual.setValue(Float.parseFloat(stoveItem.getHumidity1()));
            holder.fourSetting.setText(stoveItem.getHumidity());
            holder.fourActual.setValue(Float.parseFloat(stoveItem.getHumidity2()));
            holder.productModel.setText(stoveItem.getMaterialCode());
            holder.orderNum.setText(stoveItem.getQuantity());
        }
    }

this is setAdapter

 recyclerView.setLayoutManager(new StaggeredGridLayoutManager(6,StaggeredGridLayoutManager.VERTICAL));
        adapter = new StoveAdapter(list,this, (view,code) -> {
            //jump to other page
            Intent intent = new Intent(MainActivity.this,DetailActivity.class);
            intent.putExtra(TAG,code);
            startActivity(intent);
        });
        recyclerView.setAdapter(adapter);

this is refresh from server

 // polling from server
        subscription =  HttpMethods.getInstance().getService(SacredsunService.class)
                .getDeviceBasicData(WORK_SHOP_NAME)
                .compose(RxHelper.io_main())
                .retryWhen(errors -> errors.flatMap(error -> Observable.timer(5, TimeUnit.SECONDS)))
                .repeatWhen(completed -> completed.delay(5, TimeUnit.SECONDS))
                .subscribe((r) -> {
                    Log.d(LOG_TAG,"onNext");
                   //   this is set value
                    list.clear();
                    list.addAll(r.getItems());
                    adapter.notifyDataSetChanged();
                },(e) -> {
                    e.printStackTrace();
                },() -> {
                    Log.d(LOG_TAG,"completed");
                });

display like this
picture

thanks !!!

Position of percentage

The percentage number sometimes isn't exactly in the center of the circle. 1 out 3 times, it messes up and it slightly towards the right instead of the center.

Create new version

Could you please create a new version of the master branch with the latest bug fixes? I'm running into a deadline and would really like to use this library. Thanks in advance!

bar color is not changing it showing default bar but rim is changing

xml:-
<at.grabner.circleprogress.CircleProgressView
android:id="@+id/circleView"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginTop="@dimen/dimen8"
android:layout_marginLeft="14dp" />

//rcolo=#6CBD50
//bcolo=#D26911
mCircle2.setRimColor(Color.parseColor(rcolo));
mCircle2.setBarColor(Color.parseColor(bcolo));

is my code is correct?

unit symbol not visible in v 1.2.8

<at.grabner.circleprogress.CircleProgressView
        android:id="@+id/circleView4"
        android:layout_width="84dp"
        android:layout_height="84dp"
        android:textAlignment="center"
        android:layout_marginTop="@dimen/dimen8"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        CircleProgressView:cpv_unit="%"
        CircleProgressView:cpv_textScale="1"
        CircleProgressView:cpv_textSize="40sp"
        CircleProgressView:cpv_unitSize="30sp"
        CircleProgressView:cpv_unitPosition="right_top"
        CircleProgressView:cpv_unitScale="1"
        CircleProgressView:cpv_unitColor="@color/colorPrimary"
        CircleProgressView:cpv_showUnit="true"
        />

code using in java
int fval=Integer.parseInt(bvalu)*10;
mCircle2.setMaxValue(100);
mCircle2.setValueAnimated(fval);
mCircle2.setUnitVisible(true);
mCircle2.setUnitColor(Color.parseColor(bcolo));

    mCircle2.setRimColor(Color.parseColor(rcolo));
    mCircle2.setBarColor(Color.parseColor(bcolo));
    //colors of text and unit can be set via

mCircle2.setText("33");
mCircle2.setTextColor(Color.parseColor(bcolo));
//or to use the same color as in the gradient
// mCircle2.setAutoTextColor(true); //previous set values are ignored
mCircle2.setBarWidth(8);
mCircle2.setRimWidth(8);
mCircle2.setContourSize(0);

Starting point

Hi, nice Lib, is it possibile to set the start point of loading bar from top to left?

setBarColor not working

Hi,

I'm setting four colors for the gradient in that way:
customProgressBar.setBarColor(Color.RED, Color.BLUE, Color.GRAY, Color.GREEN);
customProgressBar.spin();

but only shows the progress with degault color, no gradient.

What I'm doing wrong?

Thanks in advance

Allow access to `mCenter`, `mXContour` to allow extensions

I would like to extend CircleProgressView so that only touch events on the outer bar are handled by this view. This allows to add buttons on the center that also control the values on the bar. For instance think of a timer with a - and + buttons.

However mCenter and mXContour are private attributes with no "getters". It'd be nice to have these attributes as protected (so that they can be accessed by child classes), or to have "getter" methods.

this are problems in listview

After I put it in a listview,it can not display progress value in normal way. There are always zero values among normal values.For example, the progress is from 0 to 100. Values should be increase continuously such as "1,2,3,4,5,6,...".But in these normal valuse many 0 will come. The result will be "1,2,3,0,0,4,0,5,0,0,6...". But if the view is not in listview it will work normally. I try to resolve it. But i failed. So please help me.

can't use CircleProgressView:textColor="@android:color/white"

Since @android:color/white is FFFFFF and you're using -1 (i.e the same value) to mean "no color specified", instead of getting white text, I'm getting the text which is the color of the bar at the current position.

My current workaround is to use FFFFFE for "close enough to white".

Seek mode

Does it have a touch mode ? I mean a mode where the value of the progress view can be modified by user when he touch circle ?

If not, what is the best way to implement that according to you ?

'cpv_unitPosition' attribute has the same value for enums: 'right_bottom' and 'right_top'

src/main/res/values/attrs.xml

    <attr name="cpv_unitPosition" format="enum">
        <enum name="top" value="0" />
        <enum name="bottom" value="1" />
        <enum name="left_top" value="2" />
        <enum name="right_top" value="3" />
        <enum name="left_bottom" value="2" />
        <enum name="right_bottom" value="3" />
    </attr>

Below enums:

  • "right_top" and "right_bottom"
  • "left_top" and "left_bottom"
    have the same values.

I believe that's the reason why "right_bottom" position is not working as expected when using xml attributes ;)

Borderless ring

Hi, is there a way to make the ring borderless, i would like it to use whole screen with no margin around it

There is a logic mistake in setting bar color


public void setBarColor(@ColorInt int... barColors) {
        this.mBarColors = barColors;
        if (mBarColors.length > 1) {
            ...
        } else if (mBarColors.length == 0) {
            mBarPaint.setColor(mBarColors[0]);
            mBarPaint.setShader(null);
        } else {
            mBarPaint.setColor(mBarColorStandard);
            mBarPaint.setShader(null);
        }
    }

Obviously we need to set standart color when mBarColors.length == 0, not otherwise))

PS gonna make a pull request soon

Value is not centered vertically

I can't manage to get my value centered vertically in the progress bar. The value seems to have its pivot at the top. So, when it grows (through auto text size or manual size) its top is aligened to the middle of the progressbar center and it grows towards the half bottom part of the progress bar. I can upload pictures if needed.

xml code:

<at.grabner.circleprogress.CircleProgressView
                android:id="@+id/circleView"
                android:layout_width="100"
                android:layout_height="100"
                android:layout_centerInParent="true"

                app:cpv_value="10"
                app:cpv_maxValue="100"
                app:cpv_barColor="@color/main_screen_progressbar_rim_fg_color"
                app:cpv_rimColor="@color/main_screen_progressbar_rim_bg_color"
                app:cpv_textColor="#FFFFFF"
                app:cpv_unitColor="#FFFFFF"
                app:cpv_spinColor="@color/main_screen_progressbar_rim_fg_color"
                app:cpv_barWidth="10dp"
                app:cpv_rimWidth="10dp"
                app:cpv_contourSize="0dp"
                app:cpv_autoTextSize="true"
                app:cpv_seekMode="true"
                app:cpv_unit="%"
                app:cpv_unitPosition="right_bottom"
                app:cpv_unitScale="1"
                app:cpv_textScale="1"
                app:cpv_showUnit="true"/>

How to add shadow on circle-progress?

How to add shadow on circle-progress?

I tried to add the shadow like this:
mBar Paint.setShadowLayer (radius, dx, dy, shadowColor);
but without success. : /

if textSize is set, unit text is positioned above circle

If the textSize attribute is set in xml, the unit text is mis-positioned; it ends up being above the circle (it's hard to see because it's cut off, but you can see the bottom pixel or so). For example, if I add

    CircleProgressView:textSize="48dp"

in ExampleApp's activity_main.xml, and then run it, I get this:

image

I assume the problem is somewhere in here, but I'm having trouble following it...

        if (update) {
            //calc unit text position
            mUnitBounds = new RectF(mOuterTextBounds.left + (mOuterTextBounds.width() * (1 - mRelativeUniteSize) * relativeGap), mOuterTextBounds.top, mOuterTextBounds.right, mOuterTextBounds.bottom);
            mUnitTextPaint.setTextSize(calcTextSizeForRect(mUnit, mUnitTextPaint, mUnitBounds) * mUnitScale);
            mUnitBounds = getTextBounds(mUnit, mUnitTextPaint, mUnitBounds);
            //move unite to top of text
            float dy = mActualTextBounds.top - mUnitBounds.top;
            mUnitBounds.offset(0, dy);
        }

Position

Is it possibile to set some margin to unit and amount of %, since is not centered.

Thanks

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.