Android VideoView: Video view is much darker in a dialog view

Jason Rogers picture Jason Rogers · Mar 9, 2011 · Viewed 10.8k times · Source

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();
                }
            });

Answer

spatialist picture spatialist · May 5, 2011

it seems that the VideoView gets dimmed because it is created behind the window. Jason Rogers solution works but means that the area behind the dialog will not get dimmed.

I used

mVideoView.setZOrderOnTop(true);

to bring the VideoView to front, so that it does not get dimmed, but still everything behind the dialog will.