【问题标题】:Android : Text in ForeGround of a FrameLayout (contain a googleMap)Android:FrameLayout 的 ForeGround 中的文本(包含 googleMap)
【发布时间】:2015-02-20 13:01:07
【问题描述】:

大家好

首先,对不起我的英语不好

我先把你放在位置上:

我在 Eclipse 中使用适用于 Android 的 Java 代码。

我的应用程序需要在片段中显示地图(Google Maps V2)以显示跑步者的位置。地图显示已经实现了。

这是我的问题:我使用 FrameLayout 元素,它包含我的地图,因此是整个页面,但是,我的目标是在地图上显示一个位于底部居中的文本框。我尝试使用 Foreground 属性选项来设置我的文本,但它不起作用(到达地图页面时应用程序崩溃)。

这是我的代码 fragment_carte:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mapFrameLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:foreground="@id/txtViewCoureur"
    tools:context=".CarteFragment" >
</FrameLayout>

我无法发布图片来向您展示我想要的东西,因为这是我的第一篇文章

在提问之前我在这个论坛上尝试了很多解决方案

感谢您的帮助!

【问题讨论】:

    标签: java android google-maps android-framelayout foreground


    【解决方案1】:

    将地图包含在 RelativeLayout 中,将其余控件包含在 FrameLayout 中。这是我拥有的一个应用程序的示例:

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
            <fragment
                android:id="@+id/mapview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentTop="true"
                class="MapFragment" />
    
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/activity_vertical_margin"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginTop="@dimen/activity_vertical_margin" >
    
                <EditText
                    android:id="@+id/mapsearchbox"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:alpha="0.8"
                    android:background="@android:color/white"
                    android:hint="@string/map_search"
                    android:imeOptions="actionSearch"
                    android:inputType="text"
                    android:paddingLeft="@dimen/activity_horizontal_margin"
                    android:paddingRight="30dp"
                    android:singleLine="true"
                    android:textColor="@android:color/black" >
                </EditText>
    
                <Button
                    android:id="@+id/mapsearchbtn
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="right|center_vertical"
                    android:layout_margin="8dp"
                    android:background="@android:drawable/ic_menu_close_clear_cancel" />
            </FrameLayout>
        </RelativeLayout>
    

    【讨论】:

    • 我已经尝试过您的解决方案,但它不起作用:/我的代码落后了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多