[我已经注意到,当我显示带有RTL标题或任何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:supportsRtl="true"
从AndroidManifest.xml
开始。它是在创建项目时默认添加的。