I am studying an Android tutorial and I am trying to access the color that I defined in colors.xml
<color name = "my_background">#3500ffff</color>
Then I try to access this color by name:
Paint background = new Paint();
background.setColor(getResources().getColor(R.color.my_background));
but it does not recognize my_background as a resource. If I let suggestions come up, only a bunch of predefined colors will appear that are not related. Any ideas? This does not make sense to me, I see almost the same from the documentation of the developer and another site , but it does not work for me.
source
share