ste*_*706 5 xml android mapbox android-studio
我正在尝试在我的Android应用程序中使用mapbox.我使用android studio 0.8.0.我在build.gradle文件中包含了这一行
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.4.0@aar'){
transitive=true
}
compile ('com.cocoahero.android:geojson:1.0.0@aar'){
transitive=true
}
Run Code Online (Sandbox Code Playgroud)
但是当我在我的xml文件中使用它时,它有一个命名空间错误.mapbox命名空间导致了这一点.任何想法可能导致什么?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/parent_layout">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15sp"
android:text="this is the general tab"/>
<com.mapbox.mapboxsdk.views.MapView -->not causing error
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:mapid="Your MapBox mapid" /> -->causing error
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
小智 10
您还可以通过在xml中添加以下行来修复此错误:
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
Run Code Online (Sandbox Code Playgroud)
XML示例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:mapid="your id" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
好吧终于解决了.我改变了我的xml文件:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/parent_layout">
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapid"
android:focusable="false"
android:focusableInTouchMode="false"
android:paddingTop="10dp"
app:mapid="your map id"
android:layout_width="match_parent"
android:layout_height="320dp" >
</com.mapbox.mapboxsdk.views.MapView>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6352 次 |
| 最近记录: |