問題描述
大家好我在對話框視圖中嵌入視頻視圖時遇到問題
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
有什么想法嗎?
這里有一些代碼
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)
這似乎是 android 的一個錯誤,其中視頻視圖是在對話框后面創(chuàng)建的,當對話框打開時,它會使包括視頻在內的背景視圖變暗
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
我應用的快速修復"是
WindowManager.LayoutParams a = dialog.getWindow().getAttributes();
a.dimAmount = 0;
dialog.getWindow().setAttributes(a);
它們可能是一個更好的解決方案,例如傳遞對話框的上下文,而不是使用相同的上下文來創(chuàng)建對話框和視頻視圖(如果有時間我會稍后檢查)
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)
這篇關于Android VideoView:對話框視圖中的視頻視圖要暗得多的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!