【发布时间】:2016-08-29 10:30:47
【问题描述】:
我在垂直滚动视图中有一个地图片段。我希望它是可滚动的。但它不工作。 我尝试从这些答案中添加透明图像以及自定义 Scrollview: how to set google map fragment inside scroll view
Google Maps API v2 SupportMapFragment inside ScrollView - users cannot scroll the map vertically
我的布局结构:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.TripDetailsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ECF0F1"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/card_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorCard"
android:orientation="vertical"
android:weightSum="12">
<TextView
android:id="@+id/tripTxt"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp"
android:layout_weight="3"
android:text="Trip"
android:textColor="@color/colorTextCard"
android:textSize="20sp" />
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_margin="10dp"
tools:context="com.example.keelindemo.Activities.Map" />
<TextView
android:id="@+id/start_point"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dp"
android:layout_weight="2"
android:drawableLeft="@drawable/flag_start"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:textColor="@color/colorTextCard" />
<TextView
android:id="@+id/end_point"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:drawableLeft="@drawable/flag_end"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:textColor="@color/colorTextCard" />
</LinearLayout>
</android.support.v7.widget.CardView>
请提出一些解决方案。我正在棉花糖上尝试一切。
【问题讨论】:
-
建议您改用
NestedScrollView- 他们添加了一些不错的增强功能,顾名思义就是“嵌套滚动”
标签: android android-layout android-maps-v2 android-maps