针对 google api7 构建的相对布局错误

发布于 2024-12-27 23:02:09 字数 1499 浏览 2 评论 0原文

我正在尝试在地图上显示设备的位置。我的应用程序可以运行,但地图无法显示。我已经阅读了大量有关此(例如地图 api 密钥)的常见错误的文章。我的手机是三星 Galaxy 2.1。我注意到我正在针对 google api8 进行构建。所以我在一些事情上搞砸了,不得不删除项目并将 src 文件复制并粘贴回新项目中。新项目现在是针对 google api7 构建的。

问题是 main.xml 文件中有错误。我唯一能想到的是我改变了项目是针对 api7 而不是 api8 构建的。有什么想法吗?

error: Error: String types not allowed (at 'layout_width' with value 'match_parent').

[编辑]错误出现在relativelayout标签中

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical" android:layout_width="match_parent" 
                android:layout_height="wrap_content" android:gravity="fill">
   <com.google.android.maps.MapView
        android:id="@+id/myGMap"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="02wE28syQIHzpwXXa95CrtA1XJLU5segJgltvKQ"

     />

   <EditText android:id="@+id/edittext1" 
             android:inputType="text"
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content" 
             />

   <Button android:layout_height="wrap_content" 
           android:layout_width="wrap_content" 
           android:text="CLOSE"
           android:layout_alignParentRight="true"  
           android:id="@+id/close" ></Button> 

</RelativeLayout>

I'm trying to display the device's position on a map. i got my app working but the map wouldn't display. I've done lots of reading on the common errors for this eg map api key. my phone is a samsung galaxy 2.1. i noticed that i was building against google api8. so i mess up a bit on a few things and had to delete the project and copy and paste the src files back into a new project. the new project is built against google api7 now.

the problem is that the main.xml file has an error in it. The only thing i can think of is that i've changed what the project is built against api7 instead of api8. any ideas?

error: Error: String types not allowed (at 'layout_width' with value 'match_parent').

[edit] the error is in the relativelayout tag

.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical" android:layout_width="match_parent" 
                android:layout_height="wrap_content" android:gravity="fill">
   <com.google.android.maps.MapView
        android:id="@+id/myGMap"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="02wE28syQIHzpwXXa95CrtA1XJLU5segJgltvKQ"

     />

   <EditText android:id="@+id/edittext1" 
             android:inputType="text"
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content" 
             />

   <Button android:layout_height="wrap_content" 
           android:layout_width="wrap_content" 
           android:text="CLOSE"
           android:layout_alignParentRight="true"  
           android:id="@+id/close" ></Button> 

</RelativeLayout>

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

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

发布评论

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

评论(1

一袭白衣梦中忆 2025-01-03 23:02:09

是的,在 api level 7 中,不存在 xml 属性 match_parent,而是需要使用 fill_parent。

Yes, in api level 7 there is no xml attibute match_parent exist, instead you need to use fill_parent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文