在视频屏幕中的垂直线显示器VideoView中播放视频时遇到问题,以下代码在三星Galaxy TabPro中工作正常,但在Android TV智能盒中运行时,垂直线出现在视频屏幕右侧.
activity_video_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<VideoView
android:id="@+id/video_activity_videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@color/black" />
<ProgressBar
android:id="@+id/video_activity_progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
VideoActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_layout);
mVideoView = (VideoView) findViewById(R.id.video_activity_videoView);
mMc = new CustomMediaController(this);
mMc.setFocusable(true);
mVideoView.setMediaController(mMc);
mVideoView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (mMc != null) mMc.show(5000);
} else {
if (mMc != null) mMc.hide();
}
}
});
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer …Run Code Online (Sandbox Code Playgroud)