在谷歌地图上方显示工具栏



我在谷歌地图上方放置工具栏时遇到问题。

我遵循了在线指示,但当我启动代码时,我看不到工具栏。

<FrameLayout
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"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/app_bar"
    android:layout="@layout/toolbar"
    android:layout_height="match_parent"
    android:layout_width="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:layout_below="@+id/app_bar"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.namexxx.app.homemap"
/>
</FrameLayout>

我根据JPCrow输入更正了代码:

<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"
android:background="@color/SecondaryBackground"
tools:context="com.example.filippo.xxx.MainActivity"
>

<include android:id="@+id/app_bar" layout="@layout/toolbar"/>

<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:layout_below="@+id/app_bar"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.filippo.xxx.homemap"
/>
</RelativeLayout>

现在它起作用了。谢谢

最新更新