java - 如何在谷歌地图上添加矩形框?

标签 java android google-maps android-studio debugging

我想在 Google Map 顶部添加 3 个框将一些文本从底部开始堆叠在一起。

注:<Button>我用它来测试谷歌地图上是否会出现任何内容。结果什么也没出现。

我是否走在实现我想要的目标的正确轨道上?我应该改变什么?

enter image description here

这是activity_maps.xml :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/searchBar"
            android:layout_width="289dp"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/searchButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:onClick="onSearch"
            android:text="SEARCH" />

    </LinearLayout>

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.mancj.example.MapsActivity">
    </fragment>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_marginBottom="20dp"
        />

</LinearLayout>

最佳答案

好吧,试试这个

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:map="http://schemas.android.com/apk/res-auto"
              xmlns:tools="http://schemas.android.com/tools"
              android:id="@+id/map"
              android:name="com.google.android.gms.maps.SupportMapFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              tools:context="com.mancj.example.MapsActivity">
    </fragment>

    <LinearLayout
        android:background="@android:color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true">

        <EditText
            android:hint="Search"
            android:id="@+id/searchBar"
            android:layout_width="289dp"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/searchButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:onClick="onSearch"
            android:text="SEARCH" />

    </LinearLayout>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:id="@+id/button2"/>

</RelativeLayout>

关于java - 如何在谷歌地图上添加矩形框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47624790/

相关文章:

java - 在 Hibernate 中使用 HQL 进行查询

java - 测试运行半个多小时

java - 由于 hive 查询错误导致 hadoop 作业出错

javascript - Google Maps API - 如果找不到一个地址,请尝试另一个地址

google-maps - Angular2 GoogleMapAPI 自动完成错误无法读取属性 'Autocomplete'

java - 添加暂停和恢复 addCircle 到 map api v2

java - 删除字符串中出现的每个字符

Java (Android) - 提取字符串中 2 个特定单词之间的部分

java - 找不到 Gradle DSL 方法 : exclude()

java - 从 ArrayList 中选取随机 ImageButton 会引发 NullPointerException