我在 StackOverflow 上进行了搜索,但没有解决我的问题。
我的 MapView 占据了我的整个屏幕。我使用了重量,但现在不起作用。 顺便说一句,它适用于 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>
它不起作用,因为您使用 fill_parent 作为高度。权重用于在总和大于LinearLayout时分配剩余的空白空间或拿走空间。将宽度设置为 0dip 即可。
关于java - MapView占据了我的整个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24755162/