0

我有一个 FrameLayout 视图,其中包含一个(类似 MapView)控件和一些覆盖它的附加按钮。(布局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>
4

2 回答 2

1

诀窍是dispatchTrackball在您的自定义视图中覆盖,并获取事件。

我希望这可以帮助别人。

于 2009-08-09T10:46:16.557 回答
0

平移只是通过之前提到的 focusable 属性实现的,将 mapview 的 focusable 属性设置为 true ,当您将 mapview 置于焦点时,它确实会使用轨迹球平移地图。

于 2011-05-20T19:58:22.930 回答