In Android System settings --> Accessibility --> Subtitle Settings
is set to very large. Content with subtitles on my Exoplayer is not rendered properly - it is overlapping when watching in portrait mode! For landscape mode it is looking nice.
(See the following attached examples for the overlapping subtitles in portrait mode)
How can I fix this? What am I doing wrong?
ExoPlayer ignores Android’s system caption settings, so you must configure subtitle styling and layout manually:
<!-- res/layout/activity_player.xml -->
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:use_controller="true"
app:subtitleStyle="@style/CustomSubtitleStyle"
app:subtitleBottomPadding="16dp" />
<!-- res/values/styles.xml -->
<style name="CustomSubtitleStyle" parent="TextAppearance.AppCompat.Caption">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:background">@android:color/black</item>
<item name="android:padding">4dp</item>
</style>
StyledPlayerView playerView = findViewById(R.id.player_view);
SubtitleView subtitleView = playerView.getSubtitleView();
subtitleView.setMaxLines(2); // or 1
CaptioningManager cm = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
float scale = cm.getFontScale();
subtitleView.setFractionalTextSize(SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * scale);
subtitleView.setStyle(SubtitleView.getUserDefaultStyleV19(this));