先上效果图
在做某个项目的夜间模式的时候,需要改变夜间模式下的icon,这时候属性修改已经不起作用了,所以需要在代码中修改。
修改的代码如下:
boolean checkedd = (Boolean) SpUtils.get(getActivity(), "night_day", false);
if (checkedd) {
setDrawableLeft(notification, R.drawable.xiaoxi2);
}
return view;
}
private void setDrawableLeft(TextView attention, int drawableId) {
Drawable drawable = getResources().getDrawable(drawableId);
Drawable rightdraw = getResources().getDrawable(R.drawable.activity_personal_right_arrows);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
attention.setCompoundDrawables(drawable, null, rightdraw, null);
}