Android中getResources().getDrawable() 过时问题分析
16lz
2021-01-26
您可以选择正确的方式处理这个弃用,具体取决于您要加载的drawable类型
(1)具有主题属性的drawables
ContextCompat.getDrawable(getActivity(), R.drawable.name);
您将获得一个样式的Drawable作为您的活动主题指示。这可能是您所需要的。
(2) drawables 没有主题属性
ResourcesCompat.getDrawable(getResources(), R.drawable.name, null);
(3) drawables with theme attributes from another theme
ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme);
翻译于:https://stackoverflow.com/questions/29041027/android-getresources-getdrawable-deprecated-api-22
更多相关文章
- 模仿墨迹天气设置界面布局
- android学习-组件中的layout-weight属性
- android 基本布局(RelativeLayout、TableLayout等)使用方法及各种
- Android(安卓)浮动搜索框 searchable 使用。
- Android(安卓)Intent应用
- AndroidMainfest.xml文件中的android属性
- Android(安卓)Animation动画效果
- axml格式
- Tools属性Tools Attributes