Android : What use is MediaController's AnchorView?

邮差的信 提交于 2019-12-10 14:18:17

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/7611591/android-what-use-is-mediacontrollers-anchorview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!