Android:MediaController 的 AnchorView 有什么用?
我希望我的 MediaController 仅当用户仅触摸屏幕的下半部分时才隐藏,因为我在顶部有一些按钮需要一键访问。 也就是说,第一次点击不会被 MediaController 拦截。
根据我在开发人员文档中读到的内容:
...具体来说,控件 将浮动在 setAnchorView() 指定的视图之上。窗户 如果闲置三秒将会消失,并且当 用户触摸锚视图。
我的anchor_view布局:
<View android:id="@+id/player_control"
android:layout_width="wrap_content"
android:layout_height="100dip"
android:layout_alignParentBottom="true">
</View >
然而,当控制器打开时,每当我触摸anchor_view之外的屏幕时,它仍然只是隐藏它,并且不会触发按钮事件。
有办法防止这种情况吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MediaController 仅将锚视图用作获取开始绘制控制器的位置的参考。控制器本身绘制在一个新的窗口中,该窗口浮动在所有视图都附加到的窗口上。当创建 MediaController 的实例时,会构建这个新的浮动窗口(使用内部 API),并将触摸侦听器与其装饰视图(即其整个表面)相关联。这就是为什么触摸屏幕的任何部分都会导致隐藏媒体控制器,这就是为什么我认为没有简单的方法来自定义此行为:它可能需要您扩展或重新实现
MediaController
。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 ofMediaController
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 reimplementMediaController
.