diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2e42b9a7097..9d9d1fa0c62 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -14,6 +14,9 @@ * Fix an issue with blind seeking to windows with non-zero offset in a `ConcatenatingMediaSource` ([#4873](https://github.com/google/ExoPlayer/issues/4873)). +* Fix issue where subtitles have a wrong position if SubtitleView has a non-zero + offset to its parent + ([#4788](https://github.com/google/ExoPlayer/issues/4788)). ### 2.9.0 ### diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java index 74266710410..50a923bced1 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java @@ -247,19 +247,17 @@ public void setBottomPaddingFraction(float bottomPaddingFraction) { @Override public void dispatchDraw(Canvas canvas) { int cueCount = (cues == null) ? 0 : cues.size(); - int rawTop = getTop(); - int rawBottom = getBottom(); + int rawViewHeight = getHeight(); - // Calculate the bounds after padding is taken into account. - int left = getLeft() + getPaddingLeft(); - int top = rawTop + getPaddingTop(); - int right = getRight() - getPaddingRight(); - int bottom = rawBottom - getPaddingBottom(); + // Calculate the cue box bounds relative to the canvas after padding is taken into account. + int left = getPaddingLeft(); + int top = getPaddingTop(); + int right = getWidth() - getPaddingRight(); + int bottom = rawViewHeight - getPaddingBottom(); if (bottom <= top || right <= left) { // No space to draw subtitles. return; } - int rawViewHeight = rawBottom - rawTop; int viewHeightMinusPadding = bottom - top; float defaultViewTextSizePx =