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
  • 175
  • 1
  • 4
  • 13

1 Answers1

2

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

azizbekian
  • 58,054
  • 12
  • 164
  • 238