如何控制Android的浏览轨迹球的行为吗?
-
06-09-2019 - |
题
我有一个包含一个(MapView的样)控制和一些额外的按钮覆盖它的FrameLayout图。 (布局XML是下文)。
我想允许用户平移/不仅使用触摸而且轨迹球滚动主视图。 问题是 - 采用了轨迹球刚接通布局的所有控件之间的焦点,而我似乎无法找到一种方法来包含 onTrackballEvent 以刚的MainView
任何建议是受欢迎的,由于事先。
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<FrameLayout android:id="@+id/pageView"
xmlns:panel="http://schemas.android.com/apk/res/com.yappa"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<MainView
android:id="@+id/mainView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</MainView>
<ZoomControls android:id="@+id/ZoomControls01"
android:layout_gravity="bottom|center"
android:layout_height="wrap_content" android:layout_width="wrap_content">
</ZoomControls>
<Panel
....
</Panel>
</FrameLayout>
</merge>
解决方案
诀窍是覆盖在自定义视图中的dispatchTrackball
,并抓住事件。
我希望这可以帮助别人。
其他提示
摇摄简单地由可聚焦属性之前提到实现,你的MapView可获得焦点的属性设置为true,它的确会平移轨迹球的地图,当你已经放置的MapView焦点。
不隶属于 StackOverflow