2016-02-03 47 views
1

我的FrameLayout的小孩MapBoxViewMapBox的Android布局无效时,父视图改变大小

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:mapbox="http://schemas.android.com/apk/res-auto"> 

    <com.mapbox.mapboxsdk.views.MapView 
     android:id="@+id/mapBoxMapView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     mapbox:access_token="@string/accessTokenMapBox"/> 

</FrameLayout> 

更改父视图的大小,但MapView类没有更新布局

我尝试打电话requsetLayout()尝试invalidateLayout() - 没有效果。

enter image description here

enter image description here

回答

1

你有没有尝试过的LinearLayout内包装你的FrameLayout所以它看起来是这样的:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:mapbox="http://schemas.android.com/apk/res-auto" 
    tools:context="com.mycompany.myfirstglapp.MainActivity" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical"> 

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     xmlns:mapbox="http://schemas.android.com/apk/res-auto"> 

     <com.mapbox.mapboxsdk.views.MapView 
      android:id="@+id/mapBoxMapView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      mapbox:access_token="@string/accessTokenMapBox"/> 

    </FrameLayout> 

除非您打算加入的对象,如在顶部的按钮然而,mapView布局,FrameLayout可以被移除。如果在运行时更改对象或大小的位置,则使用android.support.design.widget.CoordinatorLayout而不是FrameLayout也可能有所帮助。

+0

这不起作用。地图还在削减。 –

+0

如果你仍然有这个问题,我可以帮助你发布你的java代码,改变布局。现在用你发布的代码,我没有看到任何问题。 – cammace

相关问题