2017-10-10 75 views
0

我正在用Android Studio和java创建我的第一个应用程序。 我想给我的项目添加量表,我找到一个名为“sc-gauges”的库(Github)。 我添加了maven repositorie和依赖项到我的build.gradle,我可以在我的外部库中看到sc-gauges-2.6.4。我添加了一个例子,从GitHub的页面:解析XML时出错:未绑定前缀(外部库)

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:showIn="@layout/activity_main" 
tools:context="com.example.gauge.gauge.MainActivity"> 

<com.sccomponents.gauges.ScArcGauge 
    android:layout_width="300dp" 
    android:layout_height="wrap_content" 
    android:padding="30dp" 
    android:background="#f5f5f5" 
    sc:angleStart="135" 
    sc:angleSweep="270" 
    sc:strokeSize="6dp" 
    sc:progressSize="4dp" 
    sc:value="45" 
    sc:notches="8" 
    sc:notchesLength="10dp" 
    sc:textTokens="01|02|03|04|05|06|07|08" 
    sc:pointerRadius="10dp" 
    /> 

</android.support.constraint.ConstraintLayout> 

的com.sccomponents.gauges.ScArcGauge工作,但对于SC:前缀我得到一个错误:错误:(12)错误解析XML:未绑定的前缀。我觉得有一个简单的解决方案,但因为我是Java编程和Android Studio的全新手段,所以我一直无法找到它。

+0

貌似前缀“SC:”是不是在顶部布局进口同类的其他人...例如'xml:android'被导入并在下面使用,没有任何问题。看看如何将sccomponents包含进约束布局中... – deHaar

+0

我正在找它,但我找不到它。 – Ingmar05

+0

@ W0rmH0le给出了正确答案......自动资源包含 – deHaar

回答

1

给你的XML文件地址:

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

底:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:sc="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/activity_main" 
    tools:context="com.example.gauge.gauge.MainActivity"> 
相关问题