2011-12-14 73 views
1

在滚动视图中,我添加了LinearLayout。该线性布局包含textView,视频视图等。在视频拍摄时,如果我滚动屏幕视频视图连续翻转并且视频查看显示黑色背景的旧位置。在滚动屏幕时清楚地显示视频视图?

这是我的代码。

ScrollView scrl = new ScrollView(context); 
    scrl.setBackgroundColor(Color.WHITE); 

    LinearLayout llay = new LinearLayout(context);  
    llay.setOrientation(LinearLayout.VERTICAL); 

    TextView tv = new TextView(context); 
    tv.setText("before VideoView"); 
    tv.setWidth(100); 
    tv.setHeight(100); 
    llay.addView(tv); 

    VideoView video = new VideoView(context); 
    video.setLayoutParams(new LinearLayout.LayoutParams(200, 150)); 
    video.setVideoPath("/sdcard/test.mp4"); 
    video.start(); 
    llay.addView(video); 

    TextView tv1 = new TextView(context); 
    tv1.setTextColor(Color.RED); 
    tv1.setText("After VideoView"); 
    tv1.setWidth(400); 
    tv1.setHeight(500); 
    llay.addView(tv1); 

    scrl.addView(llay); 

    setContentView(scrl); 

如何在滚动屏幕时正确显示视频?

在此先感谢..

回答

2

我设法通过设置VideoView的透明背景来解决这个问题:

video.setBackgroundResource(android.R.color.transparent);

而滚动的视频仍然在闪烁,但黑箱不见了。