我需要向VideoView
添加LinearLayout
,然后将LinearLayout
添加到ViewFlipper
。这是我的代码:
LinearLayout l = new LinearLayout(this);
l.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
l.setOrientation(LinearLayout.VERTICAL);
myVideoView = new VideoView(this);
myVideoView.setVideoPath(files[i].getPath());
myVideoView.requestFocus();
myVideoView.setLayoutParams(new LayoutParams(
l.getWidth(), l.getHeight()));
myVideoView.setKeepScreenOn(true)
myVideoView.start();
myVideoView.setId(i);
l.addView(myVideoView);
vf.addView(l);
问题是我看到所有屏幕都是白色并听到视频的声音,因为视频正在播放但我看不到它。为什么?问题在哪里?
编辑:
如果我把
myVideoView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
它有效,但视频不会变慢,因为图像出现,它突然出现。我希望那个视频看起来很慢,并且像这样消失。
答案 0 :(得分:0)
试试这个:
LayoutParams layout = new LayoutParams(l.getWidth(), l.getHeight()));
...
l.addView(myVideoView, layout);
答案 1 :(得分:0)
注释myVideoView.setKeepScreenOn(true)行并检查一次。