Notification's RTL title is aligned to left instead to right

Viewed 664

I have noticed that when I show notification with RTL title or any RTL text it is aligned to left instead of right side.

The problem only occurs when:

  • the device language is set to LTR language (e.g. English) and text in notification should be RTL
  • on Android 7.1.1 RTL text is aligned to right, but on Android 10 RTL text is aligned to left

Is there a solution to show text with proper alignment no matter the device language?

How it looks right now:

RTL notification

Code:

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())
1 Answers

The solution was to remove android:supportsRtl="true" from AndroidManifest.xml. It was added by default while creating the project.

It is not worth solution, because mirrored RTL layouts in application would be LTR after that change.

Related