【发布时间】:2020-03-16 13:38:02
【问题描述】:
我注意到,当我显示带有 RTL 标题或任何 RTL 文本的通知时,它会对齐到左侧而不是右侧。
只有在以下情况下才会出现问题:
- 设备语言设置为 LTR 语言(例如英语),通知中的文本应为 RTL
- 在 Android 7.1.1 RTL 文本右对齐,但在 Android 10 RTL 文本左对齐
无论设备语言如何,是否有解决方案以正确对齐方式显示文本?
现在的样子:
代码:
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 notifications android-notifications