1

I add a VideoView to a LinearLayout and I can't make it to be visible on screen, LinearLayout is in front of it. After that LinearLayout is add to a ViewFlipper Here is my code:

    LinearLayout rr = new LinearLayout(this);
    rr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
    myVideoView = new VideoView(this);
    myVideoView.setVideoPath(Environment.getExternalStorageDirectory()
                    +"/download/"+"big_buck_bunny.mp4");
    myVideoView.requestFocus();
    myVideoView.bringToFront();

    rr.addView(myVideoView,new LayoutParams(rr.getWidth(),rr.getHeight()));
    vf.addView(rr);

Can anyone help me??? Please...Where is my mistake? I can't see it.

Gabrielle
  • 4,933
  • 13
  • 62
  • 122

1 Answers1

0

Its possible that rr.getWidth/Height() are returning a size of 0 because they have yet to be measured.

getWidth/Height() returns the size of the view in pixels, as you have specified your layout params of rr to be fill_parent,fill_parent using getWidth/Height is unnecessary.

Try replacing

rr.addView(myVideoView,new LayoutParams(rr.getWidth(),rr.getHeight()));

with

rr.addView(myVideoView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); 
triggs
  • 5,890
  • 3
  • 32
  • 31
  • you right...if I put like you sad it works but like this video appear suddenly and that is the problem...it must appear slow..I don't know how to explain better. – Gabrielle Dec 08 '11 at 15:34
  • 1
    add an animation to the linear layout,such as a fade in, see the top answer of this question http://stackoverflow.com/questions/2597329/how-to-do-a-fadein-of-an-image-on-an-android-activity-screen. – triggs Dec 08 '11 at 17:15
  • I think it is a good idea but I didn't solve my problem yet :| – Gabrielle Dec 09 '11 at 07:37