【发布时间】:2018-06-21 15:32:40
【问题描述】:
我正在为我正在开发的应用程序使用VideoView 和MediaController。我只是想让MediaController 出现在我的VideoView 之上,但显然你不能轻易做到这一点。我试图对我的VideoView id 使用setAnchorView 方法,但这不起作用。无论我做什么,MediaController 总是在我的屏幕底部。
话虽如此,我做了一些研究,看起来好像我要扩展MediaController,我可以更改位置和其他属性。我创建了一个新类:
package com.dop.mobilevforum;
import android.content.Context;
import android.widget.MediaController;
public class VFPlayer extends MediaController
{
public VFPlayer(Context context)
{
super(context);
}
}
在我的父类中:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.vforum);
controller = new VFPlayer(this);
vidPlayer = (VideoView) findViewById(R.id.vidPlayer);
vidPlayer.setMediaController(controller);
}
上面的工作正常,我的默认MediaController 仍然会弹出并具有所有相同的功能。现在的问题是,我该如何从VFPlayer 类中实际重新定位控制器?
【问题讨论】:
-
我使用this solution 来更改 MediaController 的位置。希望这对您有所帮助。
标签: android subclass mediacontroller