Android display prefix value in amount
String value = "459626854.44";
String forMatvalue = getAmountTo2Decimal(value)
SpannableString valueSuperScript = superScript(forMatvalue );
amount.setText(valueSuperScript);
private String getAmountTo2Decimal(Double value){
return (new DecimalFormat("##,##,##,##0.00")).format(value);
}
private SpannableStringBuilder superScript(String value){
String[] intArr = value.split("\\.");
String part1 = intArr[0];
String part2 = intArr[1];
SpannableStringBuilder cs = new SpannableStringBuilder(part1+"."+part2);
cs.setSpan(new SuperscriptSpan(), part1.length(), part1.length()+3,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
cs.setSpan(new RelativeSizeSpan(0.60f), part1.length(), part1.length()+3,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return cs;
}
|