android - 在 map fragment 之上设置一个 TextView

标签 android google-maps

我想创建这个布局,但我无法在 fragment 上设置文本图像。我对设置布局的要求如附图所示。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayoutFragment"
    android:layout_width="match_parent"
    android:layout_height="fill_parent" >

     <!-- ListRow Left sied Thumbnail image -->

    <LinearLayout
        android:id="@+id/thumbnail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="5dip"
        android:background="@drawable/image_bg"
        android:padding="3dip" 
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/list_image"
            android:layout_width="50dip"
            android:layout_height="50dip"
            android:src="@drawable/atm" />
    </LinearLayout>

    <!-- Name of ATM -->

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/thumbnail"
        android:layout_toRightOf="@+id/thumbnail"
        android:textColor="#040404"
        android:textSize="15dip"
        android:textStyle="bold"
        android:typeface="sans" />

    <!-- Location -->

    <TextView
        android:id="@+id/location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/title"
        android:layout_marginTop="1dip"
        android:layout_toRightOf="@+id/thumbnail"
        android:textColor="#343434"
        android:textSize="10dip" />


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

</RelativeLayout>

enter image description here

最佳答案

将 map fragment 作为第一个(顺序很重要!)放入您的RelativeLayout(因此它将位于“底部”)。然后(至少为了简单起见,我会这样做)将您想要在叠加层中的所有项目分组到另一个容器中(即 LinearLayoutRelativeLayout),将该容器放在你的观点,你基本上就完成了。

关于android - 在 map fragment 之上设置一个 TextView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17431927/

相关文章:

java - 在 fragment 中自定义ListView,我需要什么文件?

javascript - 更改 Google map 位置时遇到问题

php - 从 Gmaps 中获取草地、街道、水等信息

google-maps - Google map 信息窗口显示不正确

android - Android 项目无法在 Page Indicator 和 CirclePageIndicator 上运行

android - 填充具有 9-patch 背景的 TextView 没有视觉效果

android - 如何在 Android XML 中创建固定高度的垂直线?

android - 如何同时 "destroy"多个Android Activity

android - 从 Android 设备调用方向 API 的谷歌地图错误

javascript - Google map API - AutoSuggest 表单文本字段