Skip to content Skip to sidebar Skip to footer

Android Mediacontroller - Defining The Mediacontroller In The Layout Xml

In the android documentation on the MediaController widget I read Functions like show() and hide() have no effect when MediaController is created in an xml layout. which points

Solution 1:

I found one workaround for Android 2.x. Sadly it doesn't seem to work in 4.x.

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);

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:

The way to use this class is to instantiate it programatically.

Post a Comment for "Android Mediacontroller - Defining The Mediacontroller In The Layout Xml"