从24小时开始,我试图设置MediaControler的Anchor视图但没有成功 .

我的VideoView嵌入在更大的应用程序中,但即使使用非常简单的测试应用程序,我也不明白这个问题 .

这是我的测试活动的onCreate的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);



final VideoView vv = (VideoView) findViewById(R.id.videoView1);
vv.setVideoURI(Uri.parse("http://192.168.30.188/test.mp4"));

final MediaController mediaController = new MediaController(ll.getContext());
vv.setMediaController(mediaController);                     

vv.setOnPreparedListener(new OnPreparedListener() {

    @Override
    public void onPrepared(MediaPlayer mp) {
        mediaController.setAnchorView(vv);
    }
});

vv.requestFocus();

}

这是我简单的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >


        <FrameLayout
            android:id="@+id/layout1"

            android:layout_width="218dp"
            android:layout_height="162dp"
            android:background="@android:color/holo_purple">

        <VideoView
            android:id="@+id/videoView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        </FrameLayout>

</RelativeLayout>

看起来媒体控制器看起来与我的视频视图的底部对齐,但始终是中心的!

我看了很多堆栈溢出“解决方案”(或多或少好)或其他网站样本,我无法理解......

有人可以帮帮我吗?