Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : What use is MediaController's AnchorView?

I would like my MediaController to hide only when the user touches only the bottom half part of the screen, because i have some buttons on the top part that need to be accessible with one click. That is, without the first click being intercepted by the MediaController.

From what i read on the developers doc :

...Specifically, the controls will float above the view specified with setAnchorView(). The window will disappear if left idle for three seconds and reappear when the user touches the anchor view.

My anchor_view layout :

<View android:id="@+id/player_control" 
    android:layout_width="wrap_content"
    android:layout_height="100dip"
    android:layout_alignParentBottom="true">
</View >    

Yet, when the Controller is on, whenever i touch the screen outside the anchor_view, it still only hides it, and doesn't fire the buttons events.

Is there a way to prevent that ?

like image 246
Julie Avatar asked Oct 09 '22 21:10

Julie


1 Answers

The anchor view is used by the MediaController only as a reference to get the position where it should start to draw the controllers. Controllers themselves are drawn in a new window floating over the window which all your views are attached to. When an instance of MediaController is created, this new floating window is built (using an internal API) and a touch listener is associated to its decor view, i.e. to its whole surface. This is why touching any part of the screen results in hiding the media controllers, and this is why I believe there is no easy way to customize this behavior: it may require you to extend or reimplement MediaController.

like image 185
Giulio Piancastelli Avatar answered Oct 12 '22 10:10

Giulio Piancastelli