如果你对android很了解,这应该是一个简单的答案。我正在设计一个需要实施Google MapFragment的应用。我希望在scrollview中有一个文本区域,如下所示。但是,我想给文本提供在地图上向上滚动的效果(非常类似于找到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>
我很感激答案。如果有什么令人困惑的请问。
答案 0 :(得分:1)
我在这里解决了自己的问题。我没有尝试让地图在ScrollView后面工作,而是简单地定义了一些情况,我可以在其中更改地图的z-index以便可以访问它。例如,当我的ScrollView的scrollY值为0时,我允许地图位于顶部。我还添加了一个子句,允许用户单击spacer(覆盖地图)将视图向下滚动到底部,使地图再次出现在前面。谢谢你的帮助