0

Can anyone help me to achieve below amount string format in android application.

enter image description here

V.J.
  • 9,492
  • 4
  • 33
  • 49

3 Answers3

7

Android smartphones support writing any text in subscript or superscript . You can try with

Html.fromHtml("<sup>$</sup>1,500<sup>00</sup>");

Without using HTML tag You can visit Subscript and Superscript a String in Android

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

// For the superscript and subscript you can take help of html tag

    String yourText="$1,050<sup>00</sup>";
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        yourTextView.setText(Html.fromHtml(yourText,Html.FROM_HTML_MODE_LEGACY))
    } else {
        yourTextView.setText(Html.fromHtml(yourText));
    }
Dhaval Solanki
  • 4,589
  • 1
  • 23
  • 39
1

Just Copy past it inside your layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_centerHorizontal="true"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/dollar"
        android:text="$"
        android:textSize="40dp"
        android:gravity="top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

    <TextView
        android:layout_toRightOf="@+id/dollar"
        android:id="@+id/ammount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="80dp"
        android:layout_marginTop="-10dp"
        android:text="1,050"/>

    <TextView
        android:layout_toRightOf="@+id/ammount"
        android:id="@+id/zeroes"
        android:text="00"
        android:textSize="40dp"
        android:gravity="top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


</RelativeLayout>
  • 2
    Ohhh sorry. It is Good try but not work for me. As i have to change my layout too.. – V.J. Jun 19 '17 at 07:14