The Android Ruler

· 2 min read
The Android Ruler

Ruler in action

This image is from one of my currently under-development apps

RTL Support

Length

LTR Support by default

enter image description here

Usage

Step 1. Add it to your root build.gradle at the end of repositories:

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

Step 2. Add the dependency: Latest version:

dependencies {
        implementation 'com.github.AbdElraoufSabri:FancyAndroidRuler:<VERSION>'
}

Usage

XML

    <TextView
        android:id="@+id/value_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:textSize="32sp"
        tools:text="1" />

    <io.abdelraoufsabri.learn.ruler.widget.FancyRuler
        android:id="@+id/myScrollingValuePicker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:rulerMinValue="15"
        app:rulerMaxValue="108"
        app:rulerDefaultPosition="107.75"
        app:rulerSystem="imperial"
        app:rulerPointerColor="#FF0000FF"
        app:rulerNormalUnitBarColor="#FF0000FF"
        app:rulerMiddleUnitBarColor="#00BCD4"
        app:rulerMiddleUnitTextColor="#00BCD4"
        app:rulerQuarterUnitBarColor="#E91E63"
        app:rulerQuarterUnitTextColor="#E91E63"
        app:rulerThreeQuartersUnitBarColor="#FFEB3B"
        app:rulerThreeQuartersUnitTextColor="#FFEB3B"
        app:rulerMainUnitBarColor="#4CAF50"
        app:rulerMainUnitTextColor="#4CAF50"
        app:rulerBackgroundColor="#000"
        />

Kotlin

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        myScrollingValuePicker.setOnScrollChangedListener({
            value_text.text = myScrollingValuePicker.getReading(it).toString()
        }, 250)
    }
}

All available themes

RTL Support

RTL

LTR Support by default

LTR

Related Articles

Storm News
· 1 min read
Under Development
· 1 min read
Pet Adoption
· 1 min read
Circular Progress Bar
· 2 min read