通知的RTL标题是左对齐,而不是右对齐

问题描述 投票:0回答:1

[我已经注意到,当我显示带有RTL标题或任何RTL文本的通知时,该通知将向左对齐而不是向右对齐。

仅在以下情况下出现问题:

  • 设备语言设置为LTR语言(例如英语),通知中的文本应为RTL
  • 在Android 7.1.1 RTL文本上右对齐,但在Android 10 RTL文本上左对齐

是否有一种解决方案,无论使用哪种设备语言,都可以以正确的对齐方式显示文本?

现在的外观:

RTL notification

代码:

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个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.