I tried to integrate HelpStack with my system but everytime I tried to add it I got compilation error about predefined colors, I'm wondering why predefined android colors are not working with this project, here is the error I got:
Error: No resource found that matches the given name (at 'android:background' with value '#color/white').
I know that this can be done using res/colors.xml, but I want to use predefined colors.
Add on for #MD's answer, If you have defined white color in your resource file, Then confirm your file location.
I mean, <color name="white">#FFFFFF</color> should be in res\values folder,
Ex, If you defined it in res\values-v21 folder, and run your app under API level 21 means, which also will cause the resource not found exception.
I hope this will help you.
Related
I saw this link: how to change color of the actual scroll in ScrollView android?
Then I used android:scrollbarThumbVertical="#android:color/darker_gray"
Then I used android:scrollbarThumbVertical="#FFAAFF00"
but I saw this error:
Color types not allowed (at 'scrollbarThumbVertical' with value '#FFAAFF00')
Why is this error issued?
Why not use every color?
Try declaring your color value inside colors.xml file
<color name="light_green">#FFAAFF00</color>
and in your layout
android:scrollbarThumbVertical="#color/light_green
My Android application is using the Holo Light theme. In my layout I want to make sure I use the same color as the rest of the theme, like this:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/hint_foreground_light"
android:text="#string/welcome_city"/>
I can see that that color is defined here:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml#505
I've also tried #android:color/hint_foreground_light and ?textColorHint, but I get errors for all of them. How do I use the colors from a built-in theme?
I'm seeing errors like:
No resource found that matches the given name (at 'textColor' with value '#color/hint_foreground_light').
Resource is not public. (at 'textColor' with value '#android:color/hint_foreground_light').
No resource found that matches the given name (at 'textColor' with value '?textColorHint').
(The reason I'm even messing with setting android:textColor is because this TextView is for a Spinner and is showing up as nearly-white-on-white by default.)
The color value you referenced is indeed private and is not meant to be accessed. However, you can access it using:
android:textColor="#*android:color/hint_foreground_light"
The IDE will show an error but since, its xml, it'll compile and will also work flawlessly. This method is not recommended as you never know when will those value change or become inaccessible.
It is recommended that you simply copy the required resource in your project and reference it from there.
I have defined a custom resource file which path is :app/res/values/defaults.xml in my app,but when i use the resources in other files,the IDE show me the error like the screenshot below.I have no idea how to solve this problem.
android studio show me the error like this
The error tell you that your color cpb_default_color its not create in values/color you must create first this variable in values/colors like this
<color name="cpb_default_color">#yourHexColor</color>
Hope to help!
You should place all your colors in colors.xml
I have an android application built with Xamarin Studio. I added a file named colors.xml to the Resources/values folder. The contents were:
<resources>
<color name="ViewBackgroundColor">#ffffff</color>
</resources>
To that, I was following this approach to define and use it; however, I was trying to apply it to the view's root element (found that resource elsewhere on SO, don't have exact link). So I applied it to the view by adding android:background="#color/ViewBackgroundColor" attribute to the root element. However, this generates a build error that #color/ViewBackgroundColor isn't a value. is anybody else having this issue and is there a resolution?
To reference that color, you must use all lowercase letters.
So
android:background="#color/viewbackgroundcolor"
This is because the Xamarin tools lowercases all names to be compliant with the rules Android has for resource names.
Is also important to set "Build Action" (with mouse right button on file color.xml) as AndroidResource.
I just started android programming and i am stuck in this problem from many days , whenever i start a new project every time i get these 5 errors , i don't know what to do with them , i tried setting up whole SDK and eclipse setup but still i get these errors , Any one know about how to get rid of theses ???
R cannot be resolved to a variable
Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar',styles.xml/example/res/values-v14line 3 Android AAPT Problem
Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Light'.styles.xml/example/res/values line 3 Android AAPT Problem
Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.styles.xml/example/res/values-v11 line 3 Android AAPT Problem
For those stumbling upon this question, here's a solution: In your project.properties, change target=android-x where x < 11 to some x >= 11 e.g target=android-14, because holo was introduced first in android-11 (Honeycomb).
EDIT:
Correction, x>=14 for android:Theme.Holo.Light.DarkActionBar to work.
For error number 2,3 and 4. In your styles.xml file remove the parent="android:Theme", i used in following way
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomWindowTitleBackground">
</style>
<style name="MyTheme" parent="android:Theme">
<item name="android:windowTitleSize">65dip</item>
<item name="android:windowTitleBackgroundStyle">#style/CustomWindowTitleBackground</item>
</style>
</resources>
May i hope this will be solve your First Error. Incase your first error wont clear means, just clean the your application and then run it.
Clean your project: Project->Clean
Also, make sure you did not import "android.R". Eclipse tends to add this sometimes when you manage the imports.
when you add a resource to the project you have to update the XML Files associated with it. it will be in a folder probably named res in that folder will be several other folders called drawable layout and values they have XML Files inside them that need to be updated when you ad a resource such as a picture or a string to your project.
I might have the folders wrong, it has been a while since I programmed in Android.