views:

125

answers:

0

I am having a video resizing issue, I have to build the layout programatically, and here's my code:

    layout = new RelativeLayout(this);
    top = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
    top.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    RelativeLayout.LayoutParams middle = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    middle.addRule(RelativeLayout.BELOW, myText.getId());

    bottom = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
    bottom.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    layout.addView(myText,top);  
    layout.addView(myVideo,middle);
    layout.addView(myButtons,bottom);

    setContentView(layout);

The root layout is a relative layout. myText is a Textview that I want to add at the top of the root layout. Next, I want to add a VideoView below myText. And at the bottom of the root layout, I want to add some buttons.

myVideo is a LinearLayout defined as below:

    video = new VideoView(this);

    myVideo = new LinearLayout(this);
    myVideo.setGravity(0x11);
    videoParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    myVideo.setOrientation(LinearLayout.VERTICAL);
    myVideo.addView(video,videoParams);

In portrait mode, the video shows up in the middle with the video occupying the entire width and the right amount of height. In landscape mode, the video occupies the entire screen (which is what I want), and myText does not show up at all.

Thanks Chris