安卓VideoView:视频的观点是在一个对话框中查看更黑暗 [英] Android VideoView: Video view is much darker in a dialog view
问题描述
大家好 我有一个问题与嵌入对话视图内的视频观看
一切工作正常,除了在对话框中显示的视频是暗得多,如果显示在活动的其他
什么想法?
下面是一些code
button1main.setOnClickListener(新OnClickListener(){
公共VideoView videoView = NULL;
@覆盖
公共无效的onClick(视图v){
//设置对话框
对话对话框=新的对话框(CustomDialog.this);
dialog.setContentView(R.layout.maindialog);
//dialog.setTitle("This是我的自定义对话框);
dialog.setCancelable(真正的);
this.videoView =(VideoView)dialog.findViewById(R.id.video);
的VideoPlayer VP =新的VideoPlayer(this.videoView,NULL);
vp.playVideo();
//设置按钮
Button按钮=(按钮)dialog.findViewById(R.id.Button01);
button.setOnClickListener(新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
完();
}
});
//现在的对话框设置,它的时间来证明它
dialog.show();
}
});
其实,我找到了解决这个(或至少在我的情况)
好像它是一个错误在那里的视频观看是对话框后面创建机器人当对话框打开它变暗背景的意见,包括视频
我申请了速战速决为
WindowManager.LayoutParams A = dialog.getWindow()的getAttributes()。
a.dimAmount = 0;
。dialog.getWindow()setAttributes(一);
他们可能是一个解决方案,更好的解决方案就像传递对话框的背景下,而不是使用同样的背景下,用于创建对话框和视频显示(我将在后面检查,如果我得到曾根时间)
Hi all I have a problem with embedding a video view inside a dialog view
everything works fine except that the video displayed in the Dialog is much darker that if displayed in the rest of the activity
any ideas ?
here is some code
button1main.setOnClickListener(new OnClickListener() {
public VideoView videoView = null;
@Override
public void onClick(View v) {
//set up dialog
Dialog dialog = new Dialog(CustomDialog.this);
dialog.setContentView(R.layout.maindialog);
//dialog.setTitle("This is my custom dialog box");
dialog.setCancelable(true);
this.videoView = (VideoView) dialog.findViewById(R.id.video);
VideoPlayer vp = new VideoPlayer(this.videoView, null);
vp.playVideo();
//set up button
Button button = (Button) dialog.findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//now that the dialog is set up, it's time to show it
dialog.show();
}
});
I actually found the solution to this (or at least in my case)
it seems its a bug from android where the Video View is created behind the Dialog and when the Dialog opens it dims the background views including the video
the "quick fix" I applied is
WindowManager.LayoutParams a = dialog.getWindow().getAttributes();
a.dimAmount = 0;
dialog.getWindow().setAttributes(a);
they might be a solution better solution like passing the context of the Dialog box instead of using the same context for creating the Dialog and the Video View (I'll check later if I get sone time)
这篇关于安卓VideoView:视频的观点是在一个对话框中查看更黑暗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!