轉自:http://stackoverflow.com/questions/29041027/android-getresources-getdrawable-deprecated-api-22
-
當你這個Drawable不受主題影響時
ResourcesCompat.getDrawable(getResources(), R.drawable.name, null);
-
當你這個Drawable受當前Activity主題的影響時
ContextCompat.getDrawable(getActivity(), R.drawable.name);
-
當你這個Drawable想使用另外一個主題樣式時
ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme);