无法使用Google Map XML属性 [英] Can't use Google Map XML attributes

查看:55
本文介绍了无法使用Google Map XML属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Maps API,并且正在尝试以XML配置Google Maps的初始状态.

I'm working with Google Maps API and I'm trying to configure the initial state of Google Maps in XML.

整个XML代码:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/test_bg"
android:scaleType="centerCrop"/>

<RelativeLayout 
   android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent" >    


<RelativeLayout 
    android:id="@+id/navigation_top"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="5dp" >

    <!-- android:src="@drawable/button_back_src"    android:background="@drawable/button_background"
    android:background="@drawable/test_btn_background"-->
    <ImageButton 
        android:id="@+id/button_back"
        android:layout_width="58dp"
        android:layout_height="58dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/desc_top_button_back"

        android:background="@drawable/btn_back"
        android:scaleType="fitXY"
        android:layout_marginRight="0dp"
        android:layout_marginLeft="@dimen/standard_margin"  
        android:layout_marginTop="@dimen/standard_margin"
        android:layout_marginBottom="0dp"
          />


    <!-- android:background="@drawable/button_background" android:background="@drawable/test_btn_background" android:src="@drawable/button_options_src"-->
    <ImageButton 
        android:id="@+id/button_options"
        android:layout_width="58dp"
        android:layout_height="58dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"

        android:contentDescription="@string/desc_top_button_options"
        android:background="@drawable/btn_options"
        android:scaleType="fitXY"
        android:layout_marginRight="@dimen/standard_margin"
        android:layout_marginLeft="0dp"  
        android:layout_marginTop="@dimen/standard_margin"
        android:layout_marginBottom="0dp" />


    <!-- background, android:dropDownSelector="@drawable/spinner_selector_small"  -->
    <Spinner 
        android:id="@+id/spinner"
        android:layout_height="58dp"
        android:layout_width="wrap_content"
        android:layout_toLeftOf="@+id/button_options"
        android:layout_toRightOf="@+id/button_back"
        android:spinnerStyle="@android:style/Widget.Spinner.DropDown"
        android:background="@drawable/test_spinner_style"   
        android:padding="5dp"
        android:layout_marginRight="0dp"
        android:layout_marginLeft="0dp"  
        android:layout_marginTop="5dp"
        android:layout_marginBottom="0dp" />

</RelativeLayout>

    <LinearLayout 
        android:id="@+id/layout_checkpoints"

        android:minHeight="24dp"
        android:layout_below="@+id/navigation_top"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:background="@android:color/transparent">

    </LinearLayout>

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignTop="@+id/layout_checkpoints"
    android:layout_centerHorizontal="true"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:layout_marginLeft="@dimen/double_margin"
    android:layout_marginRight="@dimen/double_margin"
    android:layout_marginBottom="68dp" />

<LinearLayout
    android:id="@+id/rounded_corners_for_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignBottom="@+id/map"
    android:layout_alignLeft="@+id/map"
    android:layout_alignRight="@+id/map"
    android:layout_below="@+id/navigation_top"
    android:background="@drawable/round_corners"
    android:orientation="horizontal" >

</LinearLayout>

<ImageView 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:scaleType="fitXY" 
    android:src="@drawable/splash" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:id="@+id/splash_screen" 
    android:layout_alignParentBottom="true"/>

如您所见,我添加了

xmlns:map="http://schemas.android.com/apk/res-auto"

开头的FramLayout.但是,当我尝试使用map前缀时,它不会让我使用.

to FramLayout at the beginning. However, when I try to use the map prefix it won't let me.

我正在尝试这样做:

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignTop="@+id/layout_checkpoints"
    android:layout_centerHorizontal="true"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:layout_marginLeft="@dimen/double_margin"
    android:layout_marginRight="@dimen/double_margin"
    android:layout_marginBottom="68dp"
    map:uiZoomControls="false" />

但是它强调了map:uiZoomControls ="false"并指出了意外的命名空间前缀"map"等.

But it underlines the map:uiZoomControls="false" and says Unexpected namespace prefix "map" etc.

知道我在做什么错吗?

推荐答案

我认为您只需要尝试一下即可:

I think you just have to try this :

<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
map:uiZoomControls="false"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/layout_checkpoints"
android:layout_centerHorizontal="true"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_marginLeft="@dimen/double_margin"
android:layout_marginRight="@dimen/double_margin"
android:layout_marginBottom="68dp"
 />

其他想法:

  • 在片段中添加tools:ignore ="MissingPrefix"
  • 请确保已在项目中将依赖项添加到Google Play服务 (项目->属性-> Android->库,添加-> google-play-services_lib)
  • add tools:ignore="MissingPrefix" in your fragment
  • Be sur that you have add the dependency to Google Play Services in your project (Project -> Properties -> Android -> Library, Add -> google-play-services_lib)

这篇关于无法使用Google Map XML属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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