EditText which allows to append decimal numbers from right to left
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()
<attr name="rtl_decimal_points" format="integer" />
<attr name="rtl_decimal_value" format="float" />
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
<dependency>
<groupId>io.pravikant</groupId>
<artifactId>rtledittext</artifactId>
<version>1.0.0</version>
<type>aar</type>
</dependency>
Pramod Ravikant
This project is licensed under the MIT License - see the LICENSE file for details