我想在地图视图上绘制自由手绘图,以实现我通过在片段顶部添加视图并处理MotionEvents和Projection来使我的地图非交互式。 为此,我已经按下了一个按钮,点击该按钮,我可以看到我的图像视图,所以它出现在前景,地图视图在背景中,但它没有工作,所以任何人都知道我哪里出错了...我正在分享我的xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/draw_btn"
android:text="@string/button" />
<ImageView
android:id="@+id/draw_view"
android:layout_below="@+id/draw_btn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/ic_launcher"
android:visibility="gone"
/>
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_below="@+id/draw_btn"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
答案 0 :(得分:0)
试试这个..
使用LinearLayout
,方向指定为垂直,然后尝试
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/draw_btn"
android:text="@string/button" />
<ImageView
android:id="@+id/draw_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/ic_launcher"
android:visibility="gone"
/>
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
答案 1 :(得分:0)
MapView
位于ImageView
之上,因为儿童按照添加顺序彼此叠加,例如它们出现在RelativeLayout
元素中的顺序。如果在ImageView之前向上移动MapView,它将显示在ImageView下面。也许您认为android:layout_below
指的是视图的Z排序?它实际上控制着垂直位置。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent">
... button ...
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_below="@+id/draw_btn"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ImageView
android:id="@+id/draw_view"
android:layout_below="@+id/draw_btn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/ic_launcher"
android:visibility="gone" />
</RelativeLayout>
如果这不起作用,可能会有更多的窗口。例如,YouTube播放器API会在窗口中剪切一个洞,以便它可以检测到视频区域顶部显示其他视图的时间,并在发生这种情况时立即停止播放。