2016-03-30 13 views
1

ツールバーをGoogleマップの上に置くことに問題があります。Googleマップ上のツールバーを表示

私はオンラインで表示しましたが、コードを起動するとツールバーが表示されません。

<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> 
+4

最初にframelayoutを使用して、フラグメントを伝えています。android:layout_below = "@ + id/app_bar" FrameLayoutではなく相対レイアウトを使用してください。また、ツールバーの高さを次のように変更することもできます: android:layout_height = "wrap_content" android:minHeight = "?attr/actionBarSize" – JpCrow

答えて

2

私は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> 

今では動作します。ありがとう。