2

Wanted to ask. What is the right way to use VectorDrawable from resources? with support library compile 'com.android.support:support-v4:25.1.1'

Because getDrawable() is deprecated and when I use ContextCompat.getDrawable(this, R.drawable.ic_cancel_button); for setting toolbar navigation image like this

if(toolbar != null)
{
toolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.ic_cancel_button));
}

The error occures.

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_cancel_button.xml from drawable resource ID #0x7f02005e
Twinkle_Monkey
  • 185
  • 1
  • 4
  • 14

1 Answers1

3

Have a look at AppCompatResources.getDrawable(Context context, @DrawableRes int resId).

azizbekian
  • 60,783
  • 13
  • 169
  • 249