2017-10-10 69 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"> 
相關問題