如何在 MapsActivity 的底部添加一个 progressBar 和一个 textView

How to add a progressBar and a textView at the bottom of MapsActivity

我想在我的 MapsActivity 底部添加一个 progressBar 和一个 textView。

我试图拖入 activity_maps.xml 中的“设计”选项卡,但没有添加小部件。我还尝试使用“文本”选项卡添加它们,但它们仍位于 activity.

的左上角
<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.example.giacomo.miopgo2.MapsActivity" >

/>

<TextView
    android:id="@+id/txtIndirizzo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="@+id/txtIndirizzo"
    android:padding="5dp"
    android:text="Il Mio Indirizzo"

    android:visibility="visible" />

<ProgressBar
    android:id="@+id/pgbVitaGiocaotre"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout="@+id/linearLayout" />

<TextView
    android:id="@+id/txtElisir"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:text="NElisir"

    android:visibility="visible" />

不知道如何解决。感谢您的时间和考虑。

那是因为您的根布局设置不正确,请尝试以下操作:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
    android:layout_height="match_parent">

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


    <TextView
        android:id="@+id/txtIndirizzo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:padding="5dp"
        android:text="Il Mio Indirizzo"
        android:visibility="visible" />

    <ProgressBar
        android:id="@+id/pgbVitaGiocaotre"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toEndOf="@+id/txtIndirizzo"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:layout="@+id/linearLayout" />

    <TextView
        android:id="@+id/txtElisir"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toEndOf="@+id/pgbVitaGiocaotre"
        android:padding="5dp"
        android:text="NElisir"
        android:visibility="visible" />
</RelativeLayout>