2017-04-18 251 views
0

我在我的Android應用程序mapbox地圖,但它總是佔據了整個屏幕。我想讓它和下面的內容一樣大。Mapbox地圖佔據整個屏幕

這裏是我的代碼(設定一個固定的大小也不起作用):

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true" 
tools:context="com.travip.MainActivity"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

</android.support.design.widget.AppBarLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <com.mapbox.mapboxsdk.maps.MapView 
     android:id="@+id/mapview" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:text="Hello" /> 

</LinearLayout> 

+0

你能分享你的佈局文件嗎?你應該能夠在Mapbox Mapview上設置一個固定的大小。 – Tobrun

回答

1

變化

android:layout_height="wrap_content" 

android:layout_height="match_parent"

線性佈局

0

謝謝您的幫助! 我不小心叫

View rootView = inflater.inflate(R.layout.fragment_map, container, false); 

而不是

View rootView = inflater.inflate(R.layout.fragment_nearby, container, false); 

我的片段充氣錯佈局。我沒有注意到,因爲它們看起來幾乎一樣

相關問題