Alex Fan Alex Fan - 3 months ago 17
Android Question

FAB above BaiduMap MapView is visible but not touchable

I'm using Baidu Map Android SDK because I'm in China. I want to put a Float Action Button above the MapView (the effect pic is like this). But when I do this normally, the FAB is visible but not touchable. It seems that there's another touch layer of the map view on top of the FAB that cut off my touch.

What makes me even more surprised is, if I change the FAB into a common Button, it works fine when clicked.

Part of my 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>

Answer

Very easy way to handle this:

Add android:clickable="true" to the FAB.

Though I don't know why it is necessary.