我需要实现 2 个 MapViews,一个显示在屏幕的整个宽度和高度上,另一个显示在此地图的顶部,但会更小。我需要同时显示两个地图视图,显示不同的地图。我知道目前不支持此功能,但我知道可以完成变通方法,只是不确定如何在同一视图中获得两张地图并同时显示任何人有任何想法或示例?
您可以使用框架布局将视图排列在另一个视图之上。
框架布局可用于重叠视图
<FrameLayout
android:layout_width="wrap_content"
android:layout_weight="1.0"
android:layout_height="wrap_content">
<EditText
android:layout_width="fill_parent"
android:hint="Search..."
android:layout_margin="3dip"
android:id="@+id/txtsearch"
android:background="@drawable/searchback"
android:layout_height="wrap_content"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:id="@+id/btntitlesearch"
android:background="@drawable/searchbutton"/>
</FrameLayout>
这将使按钮与编辑文本重叠
使用空的 RelativeLayout 作为容器。这样,您可以将两个布局放在彼此之上。http://developer.android.com/guide/topics/ui/layout/relative.html
只需制作一个fill_parent
在你想要的任何地方制作你的第二个(比如android:layout_alignParentRight="true")
给你!
在你开始之前,我想引用谷歌关于在同一Activity
运行多个MapView
的说法:
"每个进程只支持一个MapActivity。同时运行的多个 MapActivity 可能会以意想不到和不希望的方式进行干扰。
看起来Activity
只支持一个MapView
,所以你可能想找到一个不同的设计路径。