Android : Dialog中VideoView全屏播放
前几天公司要求在引导页播放视频,如果跳转到activity去进行播放,再返回时生命周期方法调动会不太好,最后改成了在引导页构建一个Dialog,在Dialog中进行VideoView的全屏视频播放。具体代码如下:
private void playVideo(){
View dialogView=View.inflate(MainActivity.this, R.layout.activity_splash_video, null);
AlertDialog.Builder builder=new AlertDialog.Builder(MainActivity.this,R.style.SplashErrorDialogTheme);
builder.setView(dialogView);
builder.setCancelable(false);
final AlertDialog dialog=builder.create();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
lp.copyFrom(dialog.getWindow().getAttributes());
dialog.getWindow().getDecorView().setPadding(0,0,0,0);
dialog.getWindow().setAttributes(lp);
dialog.getWindow().setWindowAnimations(R.style.AnimS