Google 地图溢出就像在 foursquare 应用程序中一样

Google map overflow like in foursquare app

我正在尝试将地图集成到我的 android 应用程序中,就像在 foursquare 中一样。我需要使地图的一部分透明,然后用文字覆盖。有人知道怎么做吗?

这是一个例子:

您可以使用 RelativeLayout 并设置渐变背景:

activity_maps.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.google.android.gms.maps.SupportMapFragment" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/gradient"
        android:padding="8dp"
        android:text="Your layout here"
        android:gravity="left|center_vertical" />

</RelativeLayout>

gradient.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <gradient
        android:startColor="#ffffff"
        android:endColor="#00ffffff" />

</shape>

MapsActivity.java(微不足道,但完成了示例)

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);

        ((SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map)).getMapAsync(this);
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        Marker m = mMap.addMarker(new MarkerOptions().position(new LatLng(40, -4)));
    }
}

结果如下所示: