Context#getResources().getDrawable()方法过时后的替代方法

版权声明:本文为博主随手笔记,欢迎评论和转载。 https://blog.csdn.net/Buaaroid/article/details/51801689

博客源址:http://www.jianshu.com/p/e22d9dd93d4a

参考:Android getResources().getDrawable() deprecated API 22

1)使用drawable资源但不为其设置theme主题

ResourcesCompat.getDrawable(getResources(), R.drawable.name, null);

2)使用默认的activity主题

ContextCompat.getDrawable(getActivity(), R.drawable.name);

3)使用自定义主题

ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme);

猜你喜欢

转载自blog.csdn.net/Buaaroid/article/details/51801689