Java – change the color of the up arrow and mark it as a private warning
•
Java
After defining a custom color for the backward arrow in the action bar, a warning is 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);
Solution
Not Muhammad's
android {
lintOptions {
disable 'PrivateResource'
}
}
I recommend that you do the following, which is a declared local fix The advantage is that you don't need to disable lint checking globally (you can easily forget to activate it again later)
For XML:
tools:ignore="PrivateResource"
code:
@SuppressLint("PrivateResource")
Effectively, your code should look like this:
XML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
tools:ignore="PrivateResource" />
Code:
@SuppressLint("PrivateResource")
final Drawable upArrow = ContextCompat.getDrawable(context,R.drawable.abc_ic_ab_back_mtrl_am_alpha);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
