android 百度map 一个layout加载多个mapview,Android百度地图SDK,MapView上层按钮可见却不可触,怎么解决?...

Android 布局中,我在百度地图的地图层上层(顶层)添加一个按钮。但是添加后,按钮可以被看见,却触摸不到——触摸后还是由按钮下面的地图层在响应,似乎有一层透明的“地图触摸层”盖住了按钮。

bVCp8y

我尝试了两种布局,效果都如上所述。其中的

TextureMapView

换作

MapView

也无济于事:

<RelativeLayout>

<android.support.design.widget.FloatingActionButton/>

<com.baidu.mapapi.map.TextureMapView/>

</RelativeLayout>

<RelativeLayout>

<com.baidu.mapapi.map.TextureMapView/>

<android.support.design.widget.FloatingActionButton/>

</RelativeLayout>

不光是这个按钮,我另一个

BottomSheet

视觉上盖住百度地图的时候,触觉上仍然是地图在顶层。

请问有什么解决办法?谢谢。

UPD:

我发现如果把同一个位置的 FAB 改成普通 button 的话,button 就可以被正常点击。这就让我更疑惑了。所以补充上我的 xml 片段:

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1">

<com.baidu.mapapi.map.TextureMapView

android:id="@+id/bmapView"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:clickable="true"/>

<android.support.design.widget.FloatingActionButton

android:id="@+id/get_current_location"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/ic_gps_fixed_black_24dp"

android:layout_margin="@dimen/fab_margin"

android:layout_alignParentBottom="true"

android:layout_alignParentRight="true"

android:layout_alignParentEnd="true"/>

</RelativeLayout>

已经用非常简单的办法解决:

给 FAB 添加

android:clickable="true"

虽然不知道为什么这句必须被写上。

把你的FAB和BottomSheet放到MapView的后面。

之前也遇到过,事件分发有问题。你设置 TextureMapView的 android:clickable=”true”试试

73bccf0c0b4af35beddca4274520fb45.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值