2017-10-10 4 views
0

Je crée ma première application avec Android Studio et Java. Je veux ajouter des jauges à mon projet et j'ai trouvé une bibliothèque appelée "sc-gauges" (Github). J'ai ajouté le dépôt maven et la dépendance à mon build.gradle et je peux voir sc-gauges-2.6.4 dans mes bibliothèques externes. J'ai ajouté un exemple de la page GitHub:Erreur d'analyse XML: préfixe non lié (bibliothèque externe)

<?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> 

le com.sccomponents.gauges.ScArcGauge fonctionne mais pour le sc: préfixes que je reçois une erreur: Erreur: (12) Erreur d'analyse XML: préfixe non lié. Je me sens comme il ya une solution facile, mais depuis que je suis complètement nouveau à la programmation Java et Android Studio, je n'ai pas été en mesure de le trouver.

+0

On dirait que le préfixe « sc: » n'est pas importé dans la mise en page en haut comme les autres sont ... par exemple 'xml: android' est importé et utilisé ci-dessous sans aucun problème. Découvrez comment inclure cette chose sccomponents dans la mise en page de contrainte ... – deHaar

+0

Je cherchais fot mais je n'ai pas pu le trouver. – Ingmar05

+0

@ W0rmH0le a donné la bonne réponse ... l'inclusion automatique des ressources – deHaar

Répondre

1

Ajoutez ceci à votre fichier xml:

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

A la fin:

<?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">