【发布时间】:2016-06-16 12:31:29
【问题描述】:
我的问题:我只能在 MapView 中上下滚动,而不是左右滚动。
我的 LinearLayout 中有一个 MapView,它由嵌套滚动视图保存。所以我的 layout.xml 看起来像这样:
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
...
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_margin="10dp"
android:id="@+id/jd_map_view"/>
...
</LinearLayout>
我正在我的 Fragment 中初始化 MapView,由 TabLayout 保存,如下所示:
mapView = (MapView) mRootView.findViewById(R.id.jd_map_view);
mapView.onCreate(savedInst);
mapView.onResume();
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng latlng = new LatLng(mLat, mLng);
googleMap.addMarker(new MarkerOptions().position(latlng));
CameraUpdate center= CameraUpdateFactory.newLatLng(latlng);
CameraUpdate zoom=CameraUpdateFactory.zoomTo(14);
googleMap.moveCamera(center);
googleMap.animateCamera(zoom);
}
});
它或多或少地正常工作,这意味着我看到了一张地图,看到了我的标记,并且地图位于正确的位置。但很遗憾,我不能向右滚动...
【问题讨论】:
-
你的意思是在哪里使用框架布局?而不是线性布局或作为 MapFragment 的占位符?
-
它不起作用:/ 是否有可能,我必须强制 NestedScrollView 让触摸通过 MapView?
-
很好,谢谢 :)
标签: android google-maps scrollview android-mapview nestedscrollview