2017-04-18 4 views
0

Ich habe eine Mapbox-Karte in meiner Android App, aber sie nimmt immer den ganzen Bildschirm ein. Ich wollte es so groß machen wie den Inhalt darunter.Mapbox-Karte, die den ganzen Bildschirm einnimmt

Hier ist mein Code (eine feste Größe Einstellung funktioniert auch nicht):

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

Können Sie Ihre Layout-Datei teilen? Sie sollten in der Lage sein, eine feste Größe in einem Mapbox Mapview festzulegen. – Tobrun

Antwort

1

Änderung

android:layout_height="wrap_content" 

zu

android:layout_height="match_parent"

im linearen Layout

0

Vielen Dank für Ihre Hilfe! ich versehentlich

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

Statt

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

Mein Fragment, das das falsche Layout aufgeblasen. Ich habe es nicht bemerkt, weil sie fast gleich aussahen

Verwandte Themen