【发布时间】:2015-10-04 23:10:27
【问题描述】:
如果您对 android 非常了解,这应该是一个简单的答案。我正在设计一个需要实现 Google MapFragment 的应用程序。我想在滚动视图内有一个文本区域,如下所示。但是,我想给文本在地图上滚动的效果(非常类似于here找到的android play store效果。
为了实现这一点,我决定让滚动视图从地图顶部开始,并简单地在地图上放置一个不可见的间隔,以使文本看起来从下面开始。通过将地图视图放在滚动视图后面,触摸事件当然是“被盗”(所以我不能移动地图,放大等)。我的想法是,可能有一种方法可以让垫片的触摸事件通过 ScrollView 并被地图视图拦截。这可能吗?还是有更好的方法我应该实现它?
我的代码是这样的:
<!-- This will be the map (dynamically loaded in) -->
<fragment
...
android:layout_height="200dp"
android:id="@+id/map"
android:layout_below="@+id/searchBox"
...
/>
<!-- Note: starts under searchBox, just like @+id/map does -->
<ScrollView
...
android:layout_below="@+id/searchBox"
...
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- This is the spacer. Covers the map so that the content can be positioned under it (thus content is under the map as well) -->
<View
android:layout_width="wrap_content"
android:layout_height="200dp"
android:id="@+id/mapSpacer"/>
... The actual text content goes here
</RelativeLayout>
</ScrollView>
感谢您的回答。如果有什么令人困惑的地方,请询问。
【问题讨论】:
-
您可以尝试将 android:clickable="false" 放在您的滚动视图上,但这可能会影响滚动本身...但是,请尝试一下。
-
是的,这行不通:我只需要滚动事件通过间隔本身,因为我希望能够向上滚动文本,以及在地图视图中导航(这需要滚动或缩放等)
标签: java android google-maps scroll scrollview