我有一个滚动视图,其中有一个相对布局,其中包含顶部灵活大小的内容以及其下的地图视图。如果整个内容的高度小于屏幕视图端口(滚动视图),我希望地图视图填充下面的剩余空间。如果整个内容大于屏幕视图端口,那么我希望地图视图具有至少一定的高度。这是我所做的一个剥离版本。地图视图没有完全加载
<ScrollView 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:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/flexContent"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentTop="true"
android:background="#086dd9"
android:gravity="center"
android:text="Flexible content here"
android:textColor="@android:color/white"
android:textSize="22sp" />
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@id/flexContent"
android:background="#f73f3f"
android:minHeight="120dp"
map:mapType="normal"
tools:ignore="MissingPrefix" />
</RelativeLayout>
</ScrollView>
它将按预期工作时的全部内容的高度比屏幕视口的高度(滚动视图的高度)小。但是,如果不是,则除非地图不加载到地图视图的全高,否则一切正常。请把下面
含量比滚动型
更大正如你可以在第二张图片看到,地图视图本身是尊重在布局中设置的minHeight 120dp约束(我将地图视图的背景设为红色),但实际地图是没有加载到它的全部高度。
这怎么解决?
看看这个:http://stackoverflow.com/questions/29956014/why-should-we-use-xml-layouts – Nanoc