我有一个字符串,我必须在布局中显示。 在英语中它表现得很好,但在阿拉伯语中它很混乱: -
英文: - 2014年10月1日至2014年11月10日
阿拉伯语: - 01-Oct-2014إلى2014年11月1日
阿拉伯语呈现如上所述。我们怎样才能将阿拉伯语转移到中间?
代码中的: -
holder.mPeriodTv.setText(presenter.getViewContext().getString(R.string.bill_period, startDate, endDate));
在阿拉伯语字符串中: -
<string name="bill_period"><xliff:g id="from">%s</xliff:g> إلى <xliff:g id="todate">%s</xliff:g></string>
英文字符串: -
<string name="bill_period"><xliff:g id="from">%s</xliff:g> to <xliff:g id="todate">%s</xliff:g></string>
答案 0 :(得分:0)
String str = "\u200f" + str
\ u200f表示文字为RTL “\u200f
您的文字是从右到左”
https://android.jlelse.eu/rtl-support-on-android-here-is-all-you-need-know-e13f2df512e2
android determine if device is in right to left language/layout