0

I want to use NumberProgressBar library in my project.

I added it in gradle in this way:

dependencies {
   compile 'com.daimajia.numberprogressbar:library:1.2@aar'
}

It have predefined styles, and it is said that you can easily use it like that:

 <com.daimajia.numberprogressbar.NumberProgressBar
        android:id="@+id/number_progress_bar"
        style="@style/NumberProgressBar_Default"
  />

I want to write own style based on library style by I can't access it from my styles.xml file:

<style name="CustomProgressBar" parent="NumberProgressBar_Beauty_Red"/>

Error:(2220) Error retrieving parent for item: No resource found that matches the given name 'NumberProgressBar_Beauty_Red'.

I tried few different ways to access to it, using namespaces but it still don't work.

Is it even possible to inherit style from library? What is correct way to access of library styles?

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
Artur Latoszewski
  • 735
  • 1
  • 10
  • 21

1 Answers1

0

Are you sure that you added dependencies right way and performed Gradle Sync?

If you are not, follow these steps:

  1. File -> Project Structure...
  2. Select the app module on the left and then the Dependencies tab.
  3. Use the green + button on the right and choose Library dependency.
  4. Paste com.daimajia.numberprogressbar:library:1.2@aar
  5. OK, OK

In case you want to compare, here is my build.gradle(Module:app):

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.daimajia.numberprogressbar:library:1.2@aar'
}
Aleksandar G
  • 1,163
  • 2
  • 20
  • 25
  • Yes, I'm sure. I can use this layout but I can't access his style anywhere. – Artur Latoszewski Nov 23 '16 at 12:33
  • I'm not sure if I understand you. You are trying to create new style in **res**->**values**->**styles.xml**? – Aleksandar G Nov 23 '16 at 13:11
  • Yes. I want to create new style in my res/values/styles.xml where parent style is style defined in library styles.xml – Artur Latoszewski Nov 23 '16 at 13:30
  • Strange, cause I just did it, with your code, and without any errors. Try to delete it from dependencies (`build.gradle(Module:app)`), sync, and add again, but automated (using steps above), not manually (directly adding code in gradle). To be clear, I'm not telling you to avoid manually, because I think that you don't know how to do it , but because of some bugs that may occur. – Aleksandar G Nov 23 '16 at 14:58
  • still don't work. Maybe it's important that when I go to design tab of my layout with NumberProgressBar I have rendering problems: `Rendering Problems The following classes could not be instantiated: - com.daimajia.numberprogressbar.NumberProgressBar (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.` – Artur Latoszewski Nov 26 '16 at 16:35
  • Please do invalidate cache and restart from the File menu in Android Studio. – Madhan Dec 08 '16 at 11:52