java - MapView占据了我的整个屏幕

标签 java android xml maps

我在 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/

相关文章:

java - Android:更改一个 fragment 的应用栏高度并删除文本

android - 如何将 ListView 项目的用户名、电子邮件和地址发送到 android 中的 onItemClick 下一个 Activity

java - 返回方法无法解析为变量

java - java中缺失的鼠标填充数据

android - Android 中的外部 SD 卡(外部存储器)?

java - 如何在 toast 中显示剪贴板复制的文本

java - 在 Struts2 中处理数百个操作

java - 如何运行gulp任务和spring-boot :run together with maven?

android - 如何在android电子邮件中插入一个URL

html - 使用 XSLT 识别特定的 XHTML 单元格,并在找到它们后修改它们的属性