Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

ProtractorView in Android

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, ProtractorView is added to android. ProtractorView is a semicircular Seekbar view for selecting an angle from 0° to 180. Seek bar is a type of progress bar. Change the cursor from 0° to 180 for selecting an angle. Below is the image of ProtractorView.

ProtractorView in Android

Step By Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. The code for that has been given in both Java and Kotlin Programming Language for Android.

Step 2: Add the Required Dependencies

Navigate to the Gradle Scripts > build.gradle(Module:app) and Add the Below Dependency in the Dependencies section.

implementation 'com.github.GoodieBag:ProtractorView:v1.2'

Add the Support Library in your settings.gradle File. This library Jitpack is a novel package repository. It is made for JVM so that any library which is present in Github and Bitbucket can be directly used in the application.

dependencyResolutionManagement {
    repositories {
        // add the following
        maven { url "" }

After adding this Dependency, Sync the Project and now we will move towards its implementation.

Step 3: Working with the XML Files

Next, go to the activity_main.xml file, which represents the UI of the project. Below is the code for the activity_main.xml file. Comments are added inside the code to understand the code in more detail.


<?xml version="1.0" encoding="utf-8"?>
        app:tickProgressColor="#abe6" />
        app:layout_constraintStart_toStartOf="parent" />

Step 4: Working with the MainActivity File

Go to the MainActivity File and refer to the following code. Below is the code for the MainActivity File. Comments are added inside the code to understand the code in more detail. In this file, add interval, color, and setOnProtractorViewChangeListener to our ProtractorView. Whenever progress is changed setOnProtractorViewChangeListener is get invoked automatically. Here the changed angle value is shown in TextView. 


import android.os.Bundle;
import android.widget.TextView;
import com.goodiebag.protractorview.ProtractorView;
public class MainActivity extends AppCompatActivity {
    TextView textView;
    protected void onCreate(Bundle savedInstanceState) {
        ProtractorView protractorView = (ProtractorView) findViewById(;
          textView = findViewById(;
        protractorView.setOnProtractorViewChangeListener(new ProtractorView.OnProtractorViewChangeListener() {
            public void onProgressChanged(ProtractorView pv, int progress, boolean b) {
                textView.setText("" + progress);
            public void onStartTrackingTouch(ProtractorView pv) {
            public void onStopTrackingTouch(ProtractorView pv) {


import android.os.Build
import android.os.Bundle
import android.widget.TextView
import com.goodiebag.protractorview.ProtractorView
class MainActivity : AppCompatActivity() {
    private lateinit var textView: TextView
    override fun onCreate(savedInstanceState: Bundle?) {
        val protractorView = findViewById<ProtractorView>(
        textView = findViewById(
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        protractorView.setOnProtractorViewChangeListener(object : OnProtractorViewChangeListener() {
            fun onProgressChanged(pv: ProtractorView?, progress: Int, b: Boolean) {
                textView.text = "" + progress
            fun onStartTrackingTouch(pv: ProtractorView?) {
            fun onStopTrackingTouch(pv: ProtractorView?) {


My Personal Notes arrow_drop_up
Last Updated : 23 Nov, 2022
Like Article
Save Article
Similar Reads
Related Tutorials