bilibili / MagicaSakura

MagicaSakura 是 Android 多主题框架。~ is an Android multi theme library which supporting both daily colorful theme and night theme.
http://app.bilibili.com
Apache License 2.0
3.55k stars 468 forks source link

tintimageview 图片切换 #21

Closed shiquan18 closed 7 years ago

shiquan18 commented 7 years ago
@ColorRes
int getThemeColorId(Context context, int colorId, String theme) {
    switch (colorId) {
        case R.color.theme_color_primary:
            return context.getResources().getIdentifier(theme, "color", getPackageName());
        case R.color.theme_color_primary_dark:
            return context.getResources().getIdentifier(theme + "_dark", "color", getPackageName());
        case R.color.theme_color_primary_trans:
            return context.getResources().getIdentifier(theme + "_trans", "color", getPackageName());
    }
    return colorId;
}

private
@ColorRes
int getThemeColor(Context context, int color, String theme) {
    switch (color) {
        case 0xfffb7299:
            return context.getResources().getIdentifier(theme, "color", getPackageName());
        case 0xffb85671:
            return context.getResources().getIdentifier(theme + "_dark", "color", getPackageName());
        case 0x99f0486c:
            return context.getResources().getIdentifier(theme + "_trans", "color", getPackageName());
        case R.drawable.yellow_one:
            return context.getResources().getIdentifier(theme + "_one", "drawable", getPackageName());
        case R.drawable.red_two:
            return context.getResources().getIdentifier(theme + "_two", "drawable", getPackageName());
    }
    return -1;
}

        case R.drawable.yellow_one:
            return context.getResources().getIdentifier(theme + "_one", "drawable", getPackageName());
        case R.drawable.red_two:
            return context.getResources().getIdentifier(theme + "_two", "drawable", getPackageName());
    使用不行?
xyczero commented 7 years ago

具体使用方法可以看README,不是很懂你的用法