如何在mapview上添加textview

时间:2017-12-11 07:47:48

标签: android textview overlay android-mapview

I want to achieve something like this

这是我的代码。 所以我在mapview上使用textview但我希望textview周围的透明背景..就像它应该看起来我喜欢漂浮在mapview上

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="7"
    android:orientation="vertical"
    android:weightSum="10">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="9"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:id="@+id/location_search"
        android:drawableRight="@drawable/ic_search"
        android:text="Search" />

    <com.google.android.gms.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:apiKey="AIzaSyD_UZKqkkSN9jQBb9vRk6P4Dz6KCTSUwzU">

    </com.google.android.gms.maps.MapView>


</LinearLayout>

1 个答案:

答案 0 :(得分:1)

试试这个

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
        <TextView
            android:id="@+id/MyTextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello"
            android:layout_alignParentBottom="true" />


        <com.google.android.maps.MapView
            android:id="@+id/map"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:apiKey="Your api key"
            android:enabled="true"
            android:clickable="true"
            android:layout_above="@+id/MyTextView"" />
 </RelativeLayout>