在Google地图片段android上显示透明布局

Zee*_*med 1 xml layout android

我想在地图片段上显示透明布局,其中包括一个图像和一个文本行作为地图上的提示.当用户点击该布局时,它将变为不可见,并且将显示地图.不知道在地图上显示透明的.请帮忙.

我的地图布局是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:padding="@dimen/ten_dp" >

<fragment
    android:id="@+id/map_address"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />
Run Code Online (Sandbox Code Playgroud)

mar*_*o16 6

您只需将透明颜色设置为背景值即可

background:"@android:color/transparent"
Run Code Online (Sandbox Code Playgroud)

在您的情况下,只需添加一个布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:padding="@dimen/ten_dp" >

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

<RelativeLayout 
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@android:color/transparent">
       <TextView/>
      <ImageView/>

</RelativeLayout> 

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)