After defining a custom colour for the back arrow in the action bar, a warning is then returned. What can be done to get rid of this warning?
final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_ATOP);
actionBar.setHomeAsUpIndicator(upArrow);
The resource @drawable/abc_ic_ab_back_mtrl_am_alpha is marked as private in com.android.support:appcompat-v7
See Private Resources in Android Libraries for reason and fix.
In short, drawable/abc_ic_ab_back_mtrl_am_alpha comes from appcompat-v7 and is intended to be used only by that library. You should not use it.
If you really want to use it, copy it to your project
While I prefer to keep the Lint suppressions as close to the source as possible, as it's done in this answer, if that doesn't work it's also possible to list the suppressions in a
lint.xml
file located in yourapp
folder. It would look something like:Where issue-id is the type you want to suppress, for example UseSparseArrays. Android Studio will also autocomplete this field for you.
Instead of doing Mohammad's
I'd recommend to do the following, which is a local fix for a statement. The advantage is not having to deactivate the lint-checks globally (which can easily be forgotten to activate again later on).
For XML:
For Code:
Effectively, your code then should look something like this:
XML:
Code:
It seems it's a bug in android this post form a project member in Android Open Source Project - Issue Tracker
Replying to a similar Issue
as they said :
they are saying it was fixed but I had run through this issue today and I'm using android studio 1.5.1 and gradle 1.5