Mapbox 地图占满整个屏幕
Mapbox map taking up whole screen
我的 android 应用程序中有一个 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>
改变
android:layout_height="wrap_content"
至
android:layout_height="match_parent"
线性布局
感谢您的帮助!
我不小心打了
View rootView = inflater.inflate(R.layout.fragment_map, container, false);
而不是
View rootView = inflater.inflate(R.layout.fragment_nearby, container, false);
我的片段膨胀了错误的布局。我没有注意到,因为它们看起来几乎一样
我的 android 应用程序中有一个 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>
改变
android:layout_height="wrap_content"
至
android:layout_height="match_parent"
线性布局
感谢您的帮助! 我不小心打了
View rootView = inflater.inflate(R.layout.fragment_map, container, false);
而不是
View rootView = inflater.inflate(R.layout.fragment_nearby, container, false);
我的片段膨胀了错误的布局。我没有注意到,因为它们看起来几乎一样