我如何添加一个图形页面下面一个TextView? [英] How can I add a TextView below a MapView?

查看:126
本文介绍了我如何添加一个图形页面下面一个TextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着您好意见,谷歌地图视图现在我想添加一个的TextView 根据下面的图形页面。我只改变了布局文件的main.xml ,放在图形页面的TextView 垂直的LinearLayout 。我的Eclipse设置为自动构建这个,但是当我在模拟器中运行应用程序,我只能看到图形页面

我如何添加一个的TextView 下方的图形页面

下面是我的布局的main.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT>    < com.google.android.maps.MapView
        机器人:ID =@ + ID /图形页面
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:可点击=真
        机器人:apiKey =我的钥匙
    />    <的TextView
        机器人:ID =@ + ID / TextView的
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文字=我的TextView
    />< / LinearLayout中>


解决方案

您的问题是,你正在使用的android:layout_height =FILL_PARENT图形页面

我没有得到你想要的:


  • 的TextView 是地图上

  • 收缩的图形页面来离开空间的TextView

在第一种情况下使用< RelativeLayout的> ,而不是<的LinearLayout> 并与打的android:layout_alignParentBottom =真正的的TextView

在第二种情况下,使用的android:layout_weight 。我还没有安装Eclipse打开,但将的android:layout_weight =1的TextView 应该是足够

I followed Hello Views, Google Map View and now I want to add a TextView under below the MapView. I have only changed the layout file main.xml and placed the MapView and the TextView in a vertical LinearLayout. My Eclipse is set to build this automatically, but when I run the application in the emulator, I can only see the MapView.

How can I add a TextView below a MapView?

Here is my layout main.xml:

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

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="my key"
    />

    <TextView
        android:id="@+id/textview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="My TextView"
    />

</LinearLayout>

解决方案

The issue you have is that you are using android:layout_height="fill_parent" in your MapView.

I don't get if you want:

  • The TextView to be over the map
  • Shrink the MapView to leave space for the TextView

In the first case use a <RelativeLayout> instead of a <LinearLayout> and play with the android:layout_alignParentBottom="true" for the TextView.

In the second case, use android:layout_weight. I don't have eclipse opened but placing android:layout_weight="1"to the TextView should be enough.

这篇关于我如何添加一个图形页面下面一个TextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆