问题描述
在上的MediaController部件我读了Android文档
In the android documentation on the MediaController widget I read
像展()和隐藏()函数时,有没有效果的MediaController
在XML布局创建。
,它指向了的MediaController可以在XML布局中限定的事实。因为我想一个控制器,它永远不会隐藏,也没有走集中,这样就可以点击我试图去XML布局方式,屏幕的其余部分的按钮。正如我不能得到这个工作我在寻找如何在布局XML定义它使用的MediaController一个例子。
which points to the fact the the mediacontroller can be defined in the xml layout. As I want a controller which never hides and also doesn't take the focus so that it is possible to click buttons on the rest of the screen I tried to go the xml layout way. As I can't get this to work I am looking for an example on how to use MediaController by defining it in the layout xml.
任何暗示高度AP preciated
Any hint highly appreciated
推荐答案
我发现为Android 2.x的一种解决方法可悲的是它似乎并没有在4.x的工作。
I found one workaround for Android 2.x. Sadly it doesn't seem to work in 4.x.
您需要调用 setAnchorView()
来显示的MediaController。这code中的Android 2.2和2.3.6为我工作,但在4.0.4导致崩溃:
You need to call setAnchorView()
to show the MediaController. This code worked for me in Android 2.2 and 2.3.6, but caused crash in 4.0.4:
mediaController.setAnchorView(mediaController);
我也试过路过的活动内容以 setAnchorView()
,但它仍然在4.0.4崩溃。
I also tried passing activity content view to setAnchorView()
, but it still crashing in 4.0.4.
最可靠的方法是编程实例它作为文档说:
The most reliable way is to instantiate it programatically as said in documentation:
要使用这个类的方法是编程实例化。
这篇关于机器人的MediaController - 确定在布局XML中的MediaController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!