通知的 RTL 标题左对齐而不是右对齐
Notification's RTL title is aligned to left instead to right
我注意到当我显示带有 RTL 标题或任何 RTL 文本的通知时,它会左对齐而不是右对齐。
问题仅出现在:
- 设备语言设置为 LTR 语言(例如英语),通知中的文本应为 RTL
- 在 Android 7.1.1 RTL 文本右对齐,但在 Android 10 RTL 文本左对齐[=29=]
是否有解决方案,无论设备语言如何,都可以正确对齐显示文本?
现在的样子:
代码:
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationManager.createNotificationChannel(
NotificationChannel(CHANNEL_ID, "Test", NotificationManager.IMPORTANCE_HIGH)
)
}
val builder = NotificationCompat.Builder(this, CHANNEL_ID).apply {
setSmallIcon(R.drawable.ic_launcher_foreground)
setContentTitle("تجربة")
}
notificationManager.notify(NOTIFICATION_ID, builder.build())
解决方案是删除 android:supportsRtl="true"
来自 AndroidManifest.xml
。创建项目时默认添加。
不值得解决,因为应用程序中的镜像 RTL 布局在更改后将是 LTR。
我注意到当我显示带有 RTL 标题或任何 RTL 文本的通知时,它会左对齐而不是右对齐。
问题仅出现在:
- 设备语言设置为 LTR 语言(例如英语),通知中的文本应为 RTL
- 在 Android 7.1.1 RTL 文本右对齐,但在 Android 10 RTL 文本左对齐[=29=]
是否有解决方案,无论设备语言如何,都可以正确对齐显示文本?
现在的样子:
代码:
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationManager.createNotificationChannel(
NotificationChannel(CHANNEL_ID, "Test", NotificationManager.IMPORTANCE_HIGH)
)
}
val builder = NotificationCompat.Builder(this, CHANNEL_ID).apply {
setSmallIcon(R.drawable.ic_launcher_foreground)
setContentTitle("تجربة")
}
notificationManager.notify(NOTIFICATION_ID, builder.build())
解决方案是删除 android:supportsRtl="true"
来自 AndroidManifest.xml
。创建项目时默认添加。
不值得解决,因为应用程序中的镜像 RTL 布局在更改后将是 LTR。