布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<zippler.cn.yuewu.component.FullVideoView
android:background="#00ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:id="@+id/videoView"
/>
<ImageView
android:translationZ="10dp"
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:contentDescription="@string/preloadVideoFrame"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
重点在于VideoView中需要设置background: android:background=”#00ffffff”,透明显示底部的ImageView
为了更好的用户体验,可以在onScrollStateChanged监听器case 0 中添加:
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
ImageView img =mv.getImageView();
img.setVisibility(View.INVISIBLE);
}
},500);