ThemeManager public Drawable getTintDrawable(int drawableResId, int colorResId){ int colorId = getColorId(colorResId); Drawable drawable = getDrawable(drawableResId); drawable = ViewUtil.tintDrawable(mContext, drawable, colorId); return drawable; }public static Drawable tintDrawable(Context context, Drawable originalDrawable, int colorResId){ Drawable d = originalDrawable.getConstantState().newDrawable(); Drawable dd = d.mutate(); Drawable wrappedDrawable = DrawableCompat.wrap(dd); DrawableCompat.setTintList(wrappedDrawable, context.getResources().getColorStateList(colorResId)); return wrappedDrawable; }public Drawable getDrawable(int resId){ // if (currentContext.getPackageName().equals(mContext.getPackageName())) { // return ((ESResources)mContext.getResources()).superGetDrawable(resId); // } Drawable d = null; try { String entryName=getResourceEntryName(resId); d=getDrawable(entryName); } catch (Exception e) { // e.printStackTrace(); //handle NullPointerException if (mContext == null) mContext = FexApplication.getInstance(); Resources resources = mContext.getResources(); if(resources instanceof ESResources) d=((ESResources)resources).superGetDrawable(resId, null); else d=resources.getDrawable(resId); } //set drawable dirty when config changes (theme changes) if(d != null) d.setChangingConfigurations(d.getChangingConfigurations() | ActivityInfo.CONFIG_TOUCHSCREEN); return d; }
改变图片背景色
最新推荐文章于 2025-02-22 00:15:00 发布