Android VideoView: Video view is much darker in a dialog view(Android VideoView:对话框视图中的视频视图要暗得多)
问题描述
大家好我在对话框视图中嵌入视频视图时遇到问题
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 的一个错误,其中视频视图是在对话框后面创建的,当对话框打开时,它会使包括视频在内的背景视图变暗
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);
它们可能是一个更好的解决方案,例如传递对话框的上下文,而不是使用相同的上下文来创建对话框和视频视图(如果有时间我会稍后检查)
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:对话框视图中的视频视图要暗得多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android VideoView:对话框视图中的视频视图要暗得多


基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01