您的位置:首页 > 其它

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

2017-09-12 10:44 417 查看
博客源址: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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: