Make SubtitleWebView 'invisible' to touch events

Without this, tapping the main video playback doesn't bring up the
controls.

PiperOrigin-RevId: 291943063
This commit is contained in:
ibaker 2020-01-28 16:56:48 +00:00 committed by Oliver Woodman
parent e92ea31fcd
commit 658e0e17b8

View File

@ -22,6 +22,7 @@ import static com.google.android.exoplayer2.ui.SubtitleView.DEFAULT_TEXT_SIZE_FR
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebView; import android.webkit.WebView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -65,7 +66,22 @@ import java.util.List;
style = CaptionStyleCompat.DEFAULT; style = CaptionStyleCompat.DEFAULT;
bottomPaddingFraction = DEFAULT_BOTTOM_PADDING_FRACTION; bottomPaddingFraction = DEFAULT_BOTTOM_PADDING_FRACTION;
webView = new WebView(context, attrs); webView =
new WebView(context, attrs) {
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
// Return false so that touch events are allowed down into @id/exo_content_frame below.
return false;
}
@Override
public boolean performClick() {
super.performClick();
// Return false so that clicks are allowed down into @id/exo_content_frame below.
return false;
}
};
webView.setBackgroundColor(Color.TRANSPARENT); webView.setBackgroundColor(Color.TRANSPARENT);
addView(webView); addView(webView);
} }