Java MapView占据我的全部屏幕

Java MapView占据我的全部屏幕,java,android,xml,maps,Java,Android,Xml,Maps,我搜索了StackOverflow,但我的问题没有解决方案 我的地图视图占据了我所有的屏幕。我用过重物,但现在不行了。 顺便说一句,它对AVD有效!这太奇怪了^^ 我的java代码中有一个map.clear()。有可能吗 这是我的xml文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" and

我搜索了StackOverflow,但我的问题没有解决方案

我的地图视图占据了我所有的屏幕。我用过重物,但现在不行了。 顺便说一句,它对AVD有效!这太奇怪了^^

我的java代码中有一个map.clear()。有可能吗

这是我的xml文件:

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

     <FrameLayout 
        android:id="@+id/map_frame"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.30" > 
            <fragment
                android:id="@+id/mapView"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                />
    </FrameLayout>

    <LinearLayout
        android:id="@+id/list_establishments"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.7"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/text1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.3"
            android:text="Truc 1" />

        <TextView
            android:id="@+id/text2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Truc 2"
            android:layout_weight="0.3" />

        <TextView
            android:id="@+id/text3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Truc 3"
            android:layout_weight="0.3" />

    </LinearLayout>

</LinearLayout>

试试这个:

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

 <FrameLayout 
    android:id="@+id/map_frame"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.30" > 
        <fragment
            android:id="@+id/mapView"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            />
</FrameLayout>

<LinearLayout
    android:id="@+id/list_establishments"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_weight="0.7"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:text="Truc 1" />

    <TextView
        android:id="@+id/text2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Truc 2"
        android:layout_weight="0.3" />

    <TextView
        android:id="@+id/text3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Truc 3"
        android:layout_weight="0.3" />

</LinearLayout>

它不起作用,因为您使用“填充父对象”作为高度。当总和大于线性布局时,权重用于分配剩余的空白空间或带走空间。将宽度改为0dip,它就会工作。

使用

<com.google.android.gms.maps.MapView
                android:id="@+id/map_detail"
                android:layout_width="match_parent"
                android:layout_height="246dp" />
MapsInitializer.initialize(getActivity());      
MapView mapView = (MapView) v.findViewById(R.id.map_detail);
mapView.onCreate(savedInstanceState);
if(mapView!=null){
  GoogleMap map = mapView.getMap();
}