Android,如何使谷歌地图视图仅存在于屏幕的一部分

发布于 2024-12-15 04:18:22 字数 2967 浏览 1 评论 0原文

我正在尝试在我的应用程序中使用地图视图对象,但我需要同时显示其他信息。我希望在地图下有一些文本视图,但如果不扩展到整个屏幕,我似乎无法显示地图视图。我尝试过线性布局和相对布局。

我附上一张图像,显示底部 TextView 如何绘制在“google”徽标顶部,并隐藏其中的一部分。我希望(应该?)显示此内容(在应得的信用处给予信用)。我能想到的唯一选择是将所有文本放在地图的顶部,但我有理由不想这样做。

任何帮助和/或技巧将不胜感激。

谢谢,

Sid

这是我的代码

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.app.Activity;
import android.os.Bundle;

public class maptest extends MapActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.isti.sms.R.layout.mapviewtest);
        MapView mv = (MapView)this.findViewById(com.isti.sms.R.id.mapview);

        mv.setBuiltInZoomControls(true);
    }
    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

,xml 是

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:orientation="vertical" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/linearLayout1"
        android:layout_below="@+id/LabelArea"
        android:apiKey="my long key"
        android:clickable="true" />
</LinearLayout>

<LinearLayout
    android:id="@+id/LabelArea"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/eventinfo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:padding="5dip"
        android:text="TextView"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#0000FF" >
    </TextView>
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" >

    <TextView
        android:id="@+id/hrlegendtx"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:background="#FFFFFF"
        android:text="1 Hr"
        android:textColor="#0000FF" />
</LinearLayout>

</RelativeLayout>

显示地图底部的图像被遮挡

I'm trying to use a mapview object in my app, but I need to simultaneously display additional information. I'd like to have have some textviews under the map, but I can't seem to display the mapview without it expanding to the entire screen. I've tried both linearlayout and relativelayout.

I'm attaching an image that shows how the bottom TextView is draw on top of the "google" logo, and hides part of it. I want (should?) have this displayed (give credit where credit is due). MY only alternative that I can figure out is to put all my text at the top of the map, which I have reasons for not wanting to do.

Any help and/or tricks would be greatly appreciated.

Thanks,

Sid

Here is my code

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.app.Activity;
import android.os.Bundle;

public class maptest extends MapActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.isti.sms.R.layout.mapviewtest);
        MapView mv = (MapView)this.findViewById(com.isti.sms.R.id.mapview);

        mv.setBuiltInZoomControls(true);
    }
    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

And the xml is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:orientation="vertical" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/linearLayout1"
        android:layout_below="@+id/LabelArea"
        android:apiKey="my long key"
        android:clickable="true" />
</LinearLayout>

<LinearLayout
    android:id="@+id/LabelArea"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/eventinfo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:padding="5dip"
        android:text="TextView"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#0000FF" >
    </TextView>
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" >

    <TextView
        android:id="@+id/hrlegendtx"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:background="#FFFFFF"
        android:text="1 Hr"
        android:textColor="#0000FF" />
</LinearLayout>

</RelativeLayout>

image showing bottom of map obscured

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世俗缘 2024-12-22 04:18:22

您可以使用 LinearLayout 和 layout_weight 属性:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:apiKey="my long key"
        android:layout_weight="1"
        android:clickable="true" />
    <TextView
        android:id="@+id/hrlegendtx"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:background="#FFFFFF"
        android:text="1 Hr"
        android:textColor="#0000FF" />
</LinearLayout>

You can use LinearLayout and layout_weight property:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:apiKey="my long key"
        android:layout_weight="1"
        android:clickable="true" />
    <TextView
        android:id="@+id/hrlegendtx"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:background="#FFFFFF"
        android:text="1 Hr"
        android:textColor="#0000FF" />
</LinearLayout>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文