gpt4 book ai didi

安卓 : What use is MediaController's AnchorView?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:49:25 26 4
gpt4 key购买 nike

我希望我的 MediaController 仅在用户仅触摸屏幕的下半部分时隐藏,因为我在顶部有一些按钮需要单击一下即可访问。也就是说,第一次点击不会被 MediaController 拦截。

根据我在开发人员文档中阅读的内容:

...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.

我的 anchor_view 布局:

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

然而,当 Controller 打开时,每当我触摸 anchor_view 之外的屏幕时,它仍然只是隐藏它,并且不会触发按钮事件。

有什么办法可以避免吗?

最佳答案

MediaController 仅将 anchor View 用作获取应开始绘制 Controller 的位置的引用。 Controller 本身绘制在一个新的 窗口 中,该窗口漂浮在您的所有 View 都附加到的窗口上。当 MediaController 的实例被创建时,这个新的 float 窗口被构建(使用内部 API)并且触摸监听器被关联到它的装饰 View ,即它的整个表面。这就是为什么触摸屏幕的任何部分都会导致隐藏媒体 Controller ,这就是为什么我认为没有简单的方法来自定义此行为:它可能需要您扩展或重新实现 MediaController

关于安卓 : What use is MediaController's AnchorView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7611591/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com