The project supports RTL; Arabic in particular. The requirement is that all numbers must appear in English format even when language is selected as Arabic Locale, the way we achieve it everywhere is usually the following code in case of TextViews:
TextView t = findViewById(R.id.sampleTV);
t.setText(String.format("123",Locale.US));
Here 123 would be shown as "123" since we formatted it in US locale quite hardcoded-ly not "١٢٣"
I want to achieve the same for the Badge Notifications provided by Android Material Component's Bottom Navigation, here is what I've tried:
if(navigation!=null) {
NumberFormat nf = NumberFormat.getInstance(Locale.US);
BadgeDrawable badgeDrawable = navigation.getOrCreateBadge(R.id.nav_account);
if (badgeDrawable != null) {
if((counterNoti + counter + counterRoom) <= 0) {
badgeDrawable.setVisible(false);
badgeDrawable.clearNumber();
}
else
{
int x = counterNoti + counter + counterRoom;
nf.format(x);
badgeDrawable.setVisible(true);
badgeDrawable.setNumber(x);
}
}
(where navigation is reference to my BottomNavigation!)
Yet even with this the number is shown in Arabic not like setText's case. Is there a way to achieve this or I need an alternative?
Appreciate your input and time! Thanks.