Google Map上的TextView Bar

时间:2018-03-16 19:45:35

标签: android xml google-maps android-layout

我正在尝试使用地图实现屏幕,并且在地图的顶部应该有一个显示文本的文本栏但由于某种原因我的文本栏总是低于谷歌地图视图。 我试图查找相关的问题,但他们的答案没有成功。下面附有图片,以提供更多的礼貌。代码如下。

y.SomeDelegate(new object());

Image of desirable output

2 个答案:

答案 0 :(得分:1)

尝试下一个布局。如果您想在前面显示某些内容,则必须将其放在布局中。

修改

请尝试使用此代码。我在个人项目中使用它并在地图前显示按钮。但当然我使用的是SupportMapFragment,也许您也可以尝试使用它。

 <FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

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

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|end"
            android:gravity="top">
            <!-- Put any TextView, Imageview, Button, etc inside -->
        <LinearLayout/>
</FrameLayout>

希望它有所帮助!

答案 1 :(得分:0)

尝试在textView中使用它

android:layout_alignParentTop="true"

<强> layout_alignParentTop

  

如果为true,则使此视图的上边缘与上边缘匹配   家长。容纳上边距。

May be a boolean value, such as "true" or "false".

您也可以尝试使用

<强>机器人:layout_alignTop 使此视图的上边缘与给定锚点视图ID的上边缘匹配。容纳上边距。