自 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>
媒体控制器似乎与我的视频视图的底部对齐,但一直水平居中!
我看了很多堆栈溢出“解决方案”(或多或少好)或其他站点示例,但我无法理解......
有人可以帮帮我吗?