Finder
Finder

Reputation: 1217

Show video view clearly at the time of scrolling the screen?

With in scroll view I have added LinearLayout. That linear layout contains textView ,Video view and etc.. At the time of video palying if I scroll the screen video view flips continuously and the video views old position showing the black color background.

Here is my code.

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

How to show the video view properly at the time of scrolling the screen??

Thanks in advance..

Upvotes: 1

Views: 1543

Answers (1)

MiniGod
MiniGod

Reputation: 3802

I managed to fix this by setting the background of the VideoView to transparent:

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

The video is still flickering while scrolling, but the black box is gone.

Upvotes: 3

Related Questions