【问题标题】:Notification's RTL title is aligned to left instead to right通知的 RTL 标题左对齐而不是右对齐
【发布时间】: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


    【解决方案1】:

    解决方案是删除android:supportsRtl="true" 来自AndroidManifest.xml。它是在创建项目时默认添加的。

    不值得解决,因为应用程序中的镜像 RTL 布局在更改后将是 LTR。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-24
      • 1970-01-01
      • 2020-08-19
      • 2012-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-25
      相关资源
      最近更新 更多