MediaController Positioning

Viewed 5273

I am using VideoView to show play a local mp4 and i am using MediaController as well. The media control bar is not displaying under my video clip but in the middle of the screen. I used setAnchorView to attach it to my videoView but that had no affect. How do i position my mediacontroller to be directly under my videoview?

public class VideoDemo extends Activity {
private VideoView video;
private MediaController ctlr;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    setContentView(R.layout.main);

    File clip=new File(Environment.getExternalStorageDirectory(),
                                         "test.mp4");

    if (clip.exists()) {
        video=(VideoView)findViewById(R.id.video);
        video.setVideoPath(clip.getAbsolutePath());

        ctlr=new MediaController(this, false);
        ctlr.setAnchorView(video);
        ctlr.setMediaPlayer(video);
        video.setMediaController(ctlr);
        video.requestFocus();
    }
}
}

and my layout is

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="400dp"
    android:layout_height="400dp"
    android:background="#fff"
    >
<VideoView 
     android:id="@+id/video" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>
4 Answers

Try:

ctrl.setPadding(x, y, z, w)
Related