【问题标题】:How to allow for half SupportMapFragment and half linear layout?如何允许一半 SupportMapFragment 和一半线性布局?
【发布时间】:2014-02-11 06:23:22
【问题描述】:

我在 xml 布局中添加了一个谷歌地图片段,但它占据了整个屏幕。有谁知道是否可以允许片段的布局尺寸占据屏幕的一半和另一半线性甚至相对布局?我想出了这个模型来说明我的意思。我的布局代码也发布在下面。有人可以就这个问题给我一些建议吗?

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/map"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 class="com.google.android.gms.maps.SupportMapFragment"/>

【问题讨论】:

    标签: android android-layout google-maps-api-3 android-fragments


    【解决方案1】:

    您可以将 LinearLayout 与权重一起使用。

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical" >
    
            <fragment
                android:id="@+id/map"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                class="com.google.android.gms.maps.SupportMapFragment" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical" >
        </LinearLayout>
    
    </LinearLayout>
    

    【讨论】:

    • 是否可以在片段下方的文本框中输入目的地,片段将显示从当前位置到输入目的地的路线?或者这不是使用谷歌地图 api v3 大声说出来的吗?我很好奇,因为我在某处读到它不能大声用于行车路线..
    • @BrianJ 对此一无所知。它的 api v2 实际上
    • 哦,好吧,我认为 v2 已弃用?
    • @BrianJ 可以通过 map apiv2 top 显示从当前位置到目的地的路线
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-21
    • 2020-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多