Skip to content

EditText which allows to append decimal numbers from right to left

License

Notifications You must be signed in to change notification settings

iampravikant/RightToLeftDecimalEditText

Repository files navigation

MIT Licence

RightToLeft Decimal EditText

EditText which allows to append decimal numbers from right to left

Example

alt text

Usage

Step 1: Add RightToLeftDecimalEditText in XML

<io.pravikant.rtledittext.RightToLeftDecimalEditText
        android:id="@+id/main_weight"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Weight"
        app:rtl_decimal_points="3"
        app:rtl_decimal_value="0.000" />

Step 2 (Optional): Define decimalPoints and decimalValue in code

main_weight.setDecimalPoints(3)
main_weight.setDecimalValue(BigDecimal(56))

Step 3 (Optional): Define nextFocusableView and listener in code

main_weight.setNextFocusableView(main_width)
main_width.setNextFocusableView(main_height)
main_height.setListener(object : RightToLeftDecimalEditText.RightToLeftDecimalEditTextListener {
    override fun onKeyboardEnterClicked() {
        onSubmit()
    }
})

Step 4: Get the BigDecimal value

main_weight.getDecimalValue()

Attributes

<attr name="rtl_decimal_points" format="integer" />
<attr name="rtl_decimal_value" format="float" />

Download

Gradle:

repositories {
  mavenCentral()
  google()
}

dependencies {
  implementation 'io.pravikant:rtledittext:1.0.0'
}

Note: Don't forget to add mavenCentral() under repositories in root-level build.gradle

Maven:

<dependency>
  <groupId>io.pravikant</groupId>
  <artifactId>rtledittext</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
</dependency>

Author

Pramod Ravikant

alt text alt text alt text

Licence

This project is licensed under the MIT License - see the LICENSE file for details

About

EditText which allows to append decimal numbers from right to left

Resources

License

Stars

Watchers

Forks

Packages