CustomGauge

by pkleczko

pkleczko / CustomGauge

Simple gauge view

136 Stars 61 Forks Last release: Not found Apache License 2.0 31 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

CustomGauge

Simple gauge view

 

Installation

  • Add the following to your build.gradle:
repositories {
    jcenter()
}

dependencies { compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.4' }

  • Add "pl.pawelkleczkowski.customgauge.CustomGauge" view in your layout (example below)
  • Find CustomGauge view in your activity and use methods "setValue()" and "getValue()" to manage view

Attributes

Available view attributes:

  • startAngel (left start angel in degrees) - please be informed that gauge is drawn as an arc from startAngel (where to start) with sweepAngel (how many degrees arc is); what is more it's clockwise (right - 0, bottom - 90, left - 180, top - 270 degrees); if for example you want full circle start on 90 with 360 sweepAngel
  • sweepAngel - as described above
  • startValue - scale start value
  • endValue - scale end value
  • strokeWidth - stroke width
  • strokeColor - resource color (cannot be selector)
  • strokeCap - style of circle stroke (BUTT - straight, ROUND - rounded)
  • pointSize - defined for pointer drawn on current value (first example) - tells how wide pointer should be; if not set pointer is drawn from start value to current value (like second example)
  • pointStartColor - used for gradient pointer (second example)
  • pointEndColor - used for gradient pointer (second example)
  • dividerSize - size of divider related to values; if declared dividers will be drawn(!); e.g. if your start value is 50 and end value is 120 dividerSize set to 2 means that divider will have 1/35 of gauge total width - in other words it will have size of 2 points of gauge scale
  • dividerStep - tells how often dividers will be drawn; it's in percentage values(!); e.g. if you want to have dividers drawn each 20% of scale just set it to 20 and you will have 6 dividers drawn (with first and last)
  • dividerColor - color of divider
  • dividerDrawFirst - whether to draw first divider or no
  • dividerDrawLast - whether to draw last divider or no

Example

<pl.pawelkleczkowski.customgauge.customgauge android:id="@+id/gauge2" android:layout_width="140dp" android:layout_height="140dp" android:layout_below="@+id/gauge1" android:layout_centerhorizontal="true" android:paddingbottom="10dp" android:paddingleft="10dp" android:paddingright="10dp" android:paddingtop="10dp" app:gaugeendvalue="800" app:gaugepointendcolor="@color/md_blue_800" app:gaugepointstartcolor="@color/md_blue_300" app:gaugestartangle="135" app:gaugestartvalue="200" app:gaugestrokecap="ROUND" app:gaugestrokecolor="@color/md_grey_400" app:gaugestrokewidth="10dp" app:gaugesweepangle="270"></pl.pawelkleczkowski.customgauge.customgauge>

 

License

GNU General Public License, version 2

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.