0

我在我的应用程序中显示带有阿拉伯文本的 Toast。我在我的 strings.xml 文件中添加了阿拉伯语,例如

 <string name="gathering_locations">أماكن التجمعات . هذا قد يستغرق بضع ثوان</string>

在 strings.xml 中,看起来是正确的,但是当显示 Toast 时,消息显示为第二句首先显示,第一句显示为下一句。如何解决这个问题?任何帮助将不胜感激。

4

2 回答 2

2
Toast toast = 
Toast.maketext(getApplicationContext(),R.string.gathering_locations,
Toast.LENGTH_SHORT);
TextView tv = (TextView) toast.getView().findViewById(android.R.id.message);
if (tv != null) tv.setTextDirection(View.TEXT_Direction_RTL);
toast.show();

您必须更改 Toast 视图中的 TextView 的 TextDirection。

于 2018-08-23T12:22:38.540 回答
0

检查这个 RTL toast 库。易于使用许多自定义样式

RTL-吐司

于 2019-06-12T09:47:45.807 回答