2016-03-30 3 views
1

У меня возникли проблемы с установкой панели инструментов над картой google.Показать панель инструментов выше google map

Я следил за онлайн-индикацией, но когда я запускаю код, я не могу видеть панель инструментов.

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

Теперь она работает. Благодарю.

Смежные вопросы