格式金額字符串
回答
Android智能手機支持標或上標寫任何文字。 您可以
Html.fromHtml("<sup>$</sup>1,500<sup>00</sup>");
儘量不使用HTML標籤,您可以訪問Subscript and Superscript a String in Android
它的工作原理,但我需要的解決方案,除了HTML標籤。 –
@ V.J。看這裏例如https://stackoverflow.com/a/8872986/3383038 –
@OlegOsipenko良好的信息。 –
//對於標和下標可以採取HTML標記的幫助下
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));
}
剛過去,它複製您的佈局中:
<?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>
@ V.J。如果是你需要的,請接受 –
哦對不起。這是良好的嘗試,但不適合我。因爲我不得不改變我的佈局。 –
- 1. 如何從格式化字符串中提取貨幣金額?
- 2. 從特定字符串獲取金額
- 3. 價格字符串分成金額和貨幣
- 4. 正則表達式從字符串中獲取金額沒有貨幣符號
- 5. 格式字符串
- 6. 字符串格式
- 7. 字符串格式
- 8. 格式字符串
- 9. 打印號碼時的金額格式
- 10. 從格式化金額提取貨幣
- 11. 實時格式化美元金額
- 12. 字符串格式符號
- 13. 使用字符串格式給出字符串值的格式
- 14. 格式化printf和額外的字符串打印?
- 15. 有沒有解決方案將字符串轉換爲金額?
- 16. 從字符串中刪除一筆金額 - Javascript
- 17. 分裂貨幣及金額從字符串
- 18. 從字符串中提取美元金額 - PHP中的正則表達式
- 19. Xamarin格,列和行金額
- 20. Reg格式的字符串格式
- 21. __unicode__的Python字符串格式字符?
- 22. 字符串,字符格式崩潰
- 23. 字符串格式化
- 24. groovy字符串格式化
- 25. TimeZone字符串格式化
- 26. 格式SQL字符串
- 27. StringBuilder字符串格式
- 28. Powershell格式字符串
- 29. C#格式的字符串
- 30. 格式化的字符串
這可能需要募集的美元符號和零專門的字體。 –