Custom circular SeekBar (Circle, Semi-circle, and Ellipse) View/Widget for Android

Overview

CircularSeekBar

Android CircularSeekBar Custom View/Widget

This is a custom circular SeekBar. It can be used to create SeekBars that are:

-Full Circles

-Semi-Circles

-Ellipses

-Semi-Ellipses

In addition, it is fully customizable via XML attributes, far beyond the default values.

Support and Testing

Tested and working on Android 2.3+.

Tested on the following devices:

-HTC One Google Edition (Android 4.3)

-HTC One X (AT&T, Android 4.1)

-Galaxy Nexus (Android 4.3)

-Emulator with Android versions 2.3-4.2.

CircularSeekBar has also been tested with normal scrolling. It was also been tested successfully with Fragments, as well as scrolling tabs + Fragments.

Known Issues: -The glow effect around the progress part of the circle will not show up on Android 4.0+. This is due to the BlurMaskFilter not working when hardware acceleration is on. Android OS issue.

Screenshot 1

Documentation

In order to use the CircularSeekBar, you need to do three things.

1) Add Source Files to Project

There are two files you need to include: -CircularSeekBar.java -attrs.xml

Place the attrs.xml file inside of your res/values directory.

../yourprojectdir/res/values/attrs.xml

Place CircularSeekBar.java inside of the src folder with the entire directory structure included:

../yourprojectdir/src/com/devadvance/circularseekbar/CircularSeekBar.java

2) Customize Source Files

To use any methods inside if your classes, you must import the correct file. Add this to any classes you want to programmatically use the CircularSeekBar in:

import com.devadvance.circularseekbar.CircularSeekBar;

You also need to add the import for the generated R class to the CircularSeekBar class. You need to change the top of the CircularSeekBar.java file to look like this:

package com.devadvance.circularseekbar;

import com.example.yourappname.R;

where "com.example.yourappname" depends on your project/app. Eclipse may offer to add this import for you.

3) Add CircularSeekBar to Your Layout

Start by adding this to the root of your layout xml file(s):

xmlns:app="http://schemas.android.com/apk/res/com.devadvance.circulartest"

After you add it, the root of your layout xml file(s) should look SIMILAR to this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	xmlns:app="http://schemas.android.com/apk/res/com.devadvance.circulartest"
	android:layout_width="match_parent"
	android:layout_height="match_parent" >

To add the basic CircularSeekBar to your layout, add this to your layout xml file(s) where desired:

<com.devadvance.circularseekbar.CircularSeekBar
android:id="@+id/circularSeekBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

For further configuration, such as color, sizes, and angle, you can specify many attributes associated with the CircularSeekBar, such as:

app:start_angle="270"
app:end_angle="270"
app:circle_x_radius="100"
app:circle_y_radius="100"
app:use_custom_radii="true"
app:progress="25"
app:max="100"
app:pointer_alpha_ontouch="100"
app:pointer_color="#0174DF"
app:pointer_halo_color="#880174DF"

Note: all sizes are measured in DEGREES or DP. No pixels are used.

You can also change the standard Android view attributes, such as:

android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginTop="100dp"
android:padding="0dp"

To use the CircularSeekBar programmatically, you can treat it like a normal SeekBar inside of your code:

CircularSeekBar seekbar = (CircularSeekBar) findViewById(R.id.circularSeekBar1);
seekbar.getProgress();
seekbar.setProgress(50);

To use the listener to detect progress changes, first add the import for the class at the top of your file:

import com.devadvance.circularseekbar.CircularSeekBar.OnCircularSeekBarChangeListener;

Next, create a listener that implements the OnCircularSeekBarChangeListener:

public class CircleSeekBarListener implements OnCircularSeekBarChangeListener {
	@Override
	public void onProgressChanged(CircularSeekBar circularSeekBar, int progress, boolean fromUser) {
		// TODO Insert your code here
		
	}
}

Then create a new instance of it and set it for your seekbar:

seekbar.setOnSeekBarChangeListener(new CircleSeekBarListener());

All Available Attributes

Available Attributes:

progress - Integer Value.

max - Integer Value.

move_outside_circle - True/False. Default is false. In the case that the user has already touched down on the CircularSeekBar and is adjusting the progress, this determines whether or not movement outside the circle is accepted and adjusted the progress.

start_angle - Decimal Value. Start angle of the circle. Angles are relative to 3 o'clock (positive X axis).

end_angle - Decimal Value. End angle of the circle. Angles are relative to 3 o'clock (positive X axis).

maintain_equal_circle - True/False. Default is true. This controls whether or not an ellipse shape is available. Ellipses are not accurate in terms of representing progress, so be aware of that when you set this to false. Default value is true.

use_custom_radii - True/False. Default is false. If true, then you can specify radii using attributes. No matter what is specified, they will not exceed the bounds of the View itself. If false, then the View size (android:layout_width and android:layout_height) is used.

lock_enabled - True/False. Default is true. If true, then the progress will "stick" to the start/end point. If false, it'll just pass through.

circle_x_radius - Decimal Value. Custom X radius in DP.. Requires use_custom_radii to be true.

circle_y_radius - Decimal Value. Custom Y radius in DP. Requires use_custom_radii to be true.

circle_stroke_width - Decimal Value. Defines the width of the circle ring in DP.

pointer_radius - Decimal Value. Defines the radius of the pointer in DP.

pointer_halo_width - Decimal Value. Defines the width of the pointer halo in DP. Note: This is NOT a radius; it is in addition to the pointer radius.

pointer_halo_border_width - Decimal Value. Defines the width of the pointer halo border in DP. Note: This is NOT a radius; it is in addition to the pointer radius. The border shows up when the user is touching the CircularSeekBar.

circle_color - String value. Hex color value, can be #RRGGBB or #AARRGGBB (where AA is the alpha value).

circle_progress_color - String value. Hex color value, can be #RRGGBB or #AARRGGBB (where AA is the alpha value).

pointer_color - String value. Hex color value, can be #RRGGBB or #AARRGGBB (where AA is the alpha value).

pointer_halo_color - String value. Hex color value, can be #RRGGBB or #AARRGGBB (where AA is the alpha value). If no alpha is included, it defaults to 200 (out of 255).

pointer_alpha_ontouch - Integer value. When the user touches the CircularSeekBar, the opacity/alpha of the pointer halo changes to this value. Defaults to 100 (out of 255).

All Available Methods

The methods available to View are all present, as well as some custom methods that allow customization programmatically:

setProgress and getProgress

setMax and getMax

setCircleColor and getCircleColor

setCircleProgressColor and getCircleProgressColor

setPointerColor and getPointerColor

setPointerHaloColor and getPointerHaloColor

setPointerAlpha and getPointerAlpha

setPointerAlphaOnTouch and getPointerAlphaOnTouch

setLockEnabled and isLockEnabled

Note: Changes made with these methods are persisted by saving state.

License

 Copyright 2013 Matt Joseph

 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.

Inspired and Guided By

HoloCircleSeekBar - Copyright 2012 Jesús Manzano

HoloColorPicker - Copyright 2012 Lars Werkman (Designed by Marie Schweiz)

Although I did not used the code from either project directly, they were both used as reference material, and as a result, were extremely helpful.

Other Screenshots

![Screenshot 2](https://lh6.googleusercontent.com/-mq64-hEt_KM/Ukiy_swcllI/AAAAAAAAJD8/jy7pyKaFAaQ/w281-h500-no/2.png)

Screenshot 3

Screenshot 4

Content originally by: devadvance (+Matt Joseph)

Comments
  • Specifying attributes shows XML Parsing Error

    Specifying attributes shows XML Parsing Error

    I am able to use the Circular Seek Bar (Thanks!) and able to get progress. I am just getting errors in the XML when I add the additional styling information.

    For the "circularSeekBar1" - the error is as follows: "error: Error parsing XML: unbound prefix" Screenshot of error: http://postimg.org/image/cbge0oh4d/

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:orientation="vertical" >
    
    
    <com.neil.mytestbed.ui.CircularSeekBar
        android:id="@+id/circularSeekBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        app:circle_x_radius="100"
    
        />
    
    <TextView
        android:id="@+id/tv_circularSeekBarProgress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/circularSeekBar1"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="150dp"
        android:layout_marginRight="34dp"
        android:ems="10"
        android:inputType="textPostalAddress"
        android:text="asdasd" />            
    </RelativeLayout>
    
    opened by drupalmav 4
  • Guide me with the implementation of any of the methods.

    Guide me with the implementation of any of the methods.

    I tried this:

    @Override public void onProgressChanged(CircularSeekBar circularSeekBar, int progress, boolean fromUser) { Log.v("test", "yup"); Toast.makeText(getApplication(), "ended at", Toast.LENGTH_SHORT).show(); }

    @Override
    public void onStartTrackingTouch(CircularSeekBar circularSeekBar) {
        // TODO Auto-generated method stub
        Log.v("test", "start");
    }
    
    @Override
    public void onStopTrackingTouch(CircularSeekBar circularSeekBar) {
        // TODO Auto-generated method stub
        Log.v("test", "stop");
    }
    

    LogCat shows the texts successfully in all the three methods. But if any Task is given, to show a Toast or to change a string in TextView...for example here a Toast, it says:

    "02-07 06:30:30.272: E/AndroidRuntime(5866): FATAL EXCEPTION: main 02-07 06:30:30.272: E/AndroidRuntime(5866): Process: com.ui.yogeshblogspot, PID: 5866 02-07 06:30:30.272: E/AndroidRuntime(5866): java.lang.NullPointerException 02-07 06:30:30.272: E/AndroidRuntime(5866): at android.widget.Toast.(Toast.java:93) 02-07 06:30:30.272: E/AndroidRuntime(5866): at android.widget.Toast.makeText(Toast.java:241) 02-07 06:30:30.272: E/AndroidRuntime(5866): at com.ui.yogeshblogspot.CustomSeekBarExActivity.onProgressChanged(CustomSeekBarExActivity.java:76) 02-07 06:30:30.272: E/AndroidRuntime(5866): at com.devadvance.circularseekbar.CircularSeekBar.onTouchEvent(CircularSeekBar.java:699) 02-07 06:30:30.272: E/AndroidRuntime(5866): at android.view.View.dispatchTouchEvent(View.java:7690) 02-07 06:30:30.272: E/AndroidRuntime(5866): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216) "

    Shows a problem here in 'circularseekbar.java' on 'LINE 683'

    if (mOnCircularSeekBarChangeListener != null) { here>>>> mOnCircularSeekBarChangeListener.onProgressChanged(this, mProgress, true); }

    not letting me do anything on events. Please let me know Thanks.

    opened by sud007 2
  • Add to Jitpack

    Add to Jitpack

    Would be great if you add your library to Jitpack so others can use it using Jitpack's maven repository. Check out this link for instructions: https://www.jitpack.io/#devadvance/circularseekbar

    opened by heinrichreimer 1
  • Disable user to make changes

    Disable user to make changes

    Is it possible to disable user to make some changes? For example, after user reach certain level I would like to remove option to make other changes. I tried to set clickable to false, but that did not changed nothing. Also I tried using method setEnabled(false), but without success.

    opened by andrija-scepan 1
  • Pull in private to protected and isTouchEnabled changes

    Pull in private to protected and isTouchEnabled changes

    This is to pull in the following changes: -Changing everything from private to protected to allow proper subclasses -Adding the option to disable user interaction (touch)

    opened by devadvance 0
  • Can we make  circular_x_radius  to occupy the mobile/tablet width

    Can we make circular_x_radius to occupy the mobile/tablet width

    Hi , I am trying to make this circularseekbar to occupy the entire screen width of a mobile/tablet. Is there any method or way to do achieve this. I am only unable to set app:circle_x_radius="100" which is a numerical value. is there anyway to set app:circle_x_radius="wrap_content"

    opened by PrudhviRaju123 0
  • restrict user to move pointer

    restrict user to move pointer

    @devadvance Hi, I want to restrict user to touch or move pointer at specific progress. For ex,if i reach 15 of progress then user will not move to the pointer in after 15.it will be move before 15. is it possible?i have tried so much but can't getting output as i expected. If any solution then please send me on my id [email protected]

    opened by dipalikcspl 1
  • Sometimes progress value is jumped from 0 to 100.

    Sometimes progress value is jumped from 0 to 100.

    The current thumb is at value of 0. When changing the seek bar speedy, the value jumps to 100. I suspect the following code block.

    else if (lockAtEnd && lockEnabled) { mProgress = mMax; // Suspected here. recalculateAll(); invalidate(); if (mOnCircularSeekBarChangeListener != null) { mOnCircularSeekBarChangeListener.onProgressChanged(this, mProgress, true); } }

    opened by iraj-wisilica 0
Owner
Matt Joseph
Innovator, engineer, photographer, open source advocate
Matt Joseph
Circular SeekBar view for Android

SeekArc What is a SeekArc? So what the heck is a SeekArc? Essentially it’s a SeekBar that has been wrapped around a circle. It acts like a SeekBar and

Neil Davies 870 Dec 10, 2022
StartPointSeekBar is a custom view for the Android platform that makes it possible to have a SeekBar to have custom start point.

Forked/Inspired from https://code.google.com/p/range-seek-bar/ by [email protected] This solves the problem as described in http://

Gaurav Vashisth 142 Dec 29, 2022
Ranger is custom view which able to act like android seekbar.

Ranger is custom view which able to act like android seekbar.

Enes Zor 3 Oct 17, 2021
 A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)

文档还是中文好 Demo APK download fir.im Usage Dependencies Release Version allprojects { repositories { ... maven { url 'https://jitpack.io' }

null 2.3k Jan 5, 2023
Simple custom Android View providing a Circular spin to SeekBars

CircularSeekBar This is a simple Seek Bar, in the shape of a circle, responsive to the speed of the spin: the faster you spin the control, the faster

Mikel 34 Feb 18, 2022
A seekbar contains two cursor(left and right). Multiple touch supported.

RangeSeekbar A seekbar contains two cursor and support multi-touch. RangeSeekbar have left and right cursors, user can move cursor to make fliter. How

dolphinWang 283 Mar 28, 2022
A color picker seekbar for android.

ColorSeekBar A color picker seekbar for android. Download Use Gradle compile 'com.divyanshu.colorseekbar:colorseekbar:1.0.2' or Maven <dependency>

Divyanshu Bhargava 129 Nov 29, 2022
A SeekBar suited for showing a preview of something. As seen in Google Play Movies.

PreviewSeekBar A SeekBar suited for showing a video preview. As seen in Google Play Movies Google Play Movies PreviewSeekBar's sample Build Add the fo

Rúben Sousa 3.3k Jan 3, 2023
A colorful SeekBar for picking color

ScreenShot: Attrs attr format default colorSeeds references colorBarPosition integer 0 alphaBarPosition integer 0 maxPosition integer 100 bgColor colo

Jack Fu 324 Dec 26, 2022
A circular seek bar for Android

CircularSeekBar A circular seek bar for Android. Modification 1. Modified setProgress(int progress) method. 2. Added hideSeekBar() To hide seekbar. 3.

Raghav Sood 289 Nov 25, 2022
Android widget for selecting a range of values.

MaterialRangeBar MaterialRangeBar is a fork from https://github.com/edmodo/range-bar that adds some basic material styling, as well as start and end v

null 1.7k Dec 30, 2022
A simple material-based support library to bring consistent SeekBars on Android 14 and above

SeekBarCompat A support library for the material design SeekBar in Android for API 14 and above. Screenshot On APIs 14 and above - Seekbars would look

Ahmed Rizwan 157 Dec 27, 2022
Android circle seekbar widget inspired from: https://github.com/LarsWerkman/HoloColorPicker

Android HoloCircleSeekBar A Circle SeekBar inspired by Android Holo ColorPicker designed by Marie Schweiz and developed by Lars Werkman. How to integr

Jesus 232 Nov 10, 2022
Circular SeekBar view for Android

SeekArc What is a SeekArc? So what the heck is a SeekArc? Essentially it’s a SeekBar that has been wrapped around a circle. It acts like a SeekBar and

Neil Davies 870 Dec 10, 2022
StartPointSeekBar is a custom view for the Android platform that makes it possible to have a SeekBar to have custom start point.

Forked/Inspired from https://code.google.com/p/range-seek-bar/ by [email protected] This solves the problem as described in http://

Gaurav Vashisth 142 Dec 29, 2022
A beautiful Android custom View that works similar to a range or seekbar. With animations.

ValueBar A beautiful Android custom View that works similar to a range or seekbar. Selection by gesture. With animations. Supporting API level 11+. De

Philipp Jahoda 147 Nov 20, 2022
Ranger is custom view which able to act like android seekbar.

Ranger is custom view which able to act like android seekbar.

Enes Zor 3 Oct 17, 2021
Improve automated and semi-automated active scanning in Burp Pro

PentagridScanController Improve automated and semi-automated active scanning for BurpSuite Author: Tobias "floyd" Ospelt, @floyd_ch, http://www.floyd.

Pentagrid AG 48 Dec 13, 2022
 A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)

文档还是中文好 Demo APK download fir.im Usage Dependencies Release Version allprojects { repositories { ... maven { url 'https://jitpack.io' }

null 2.3k Jan 5, 2023
Simple and easy to use circular menu widget for Android.

Deprecated This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to

Anup Cowkur 420 Nov 25, 2022