在地图片段顶部设置一个文本视图 [英] Set a textview on top of a Map Fragment

查看:76
本文介绍了在地图片段顶部设置一个文本视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建此布局,但我无法在片段上设置文本图像。我设置布局的要求与我在附图中显示的一样。

 <?xml version =1.0encoding =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 :取向= 水平 >

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

<! - 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/>

<! - - 位置 - >

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>

!)在你的 RelativeLayout 中(所以它会在底部)。然后(至少我会这样做是为了简单)将你想要叠加到另一个容器中的所有项目(即 LinearLayout RelativeLayout ),将容器放置在视图的顶部,并且大部分都已完成。


I want to create this layout, but I am unable to set the Text Image on the fragment. My requirement to set the layout is as I show in the attached image.

<?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>

解决方案

Put map fragment as first one (order matters!) in your RelativeLayout (so it will be on "bottom"). Then (at least I'd do that for simplicity) group all items you want in your overlay in another container (i.e. LinearLayout or RelativeLayout), position that container on top of your view and you are mostly done.

这篇关于在地图片段顶部设置一个文本视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆