[英]Adding custom footer buttons to Google Maps Marker on Android
当我在MapFragment中单击Marker时,地图底部会出现两个按钮(用于路径和搜索)。 我该如何自定义这些按钮?
我在这里搜索了一些提示,但只找到了如何在信息窗口中添加按钮......
谢谢。
您可以使用带有3 FrameLayout
,并将底部按钮的android:visibility
设置为invisible
。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
/>
<Button
android:layout_gravity="bottom|left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:text="Button 1"/>
<Button
android:layout_gravity="bottom|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:text="Button 2"
/>
</FrameLayout>
(如果你没有设置android:visibility="invisible"
,你可以在mapFragment的底部看到这两个按钮,见下图)
在onMarkerClick
方法中,您可以将这两个按钮的不可见性更改为可见的示例代码:
button1.setVisibility(View.VISIBLE);
button2.setVisibility(View.VISIBLE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.