Colorful 主题调色

地址:https://github.com/garretyoder/Colorful

Colorful是一个简单又好用的帮助库,相对比为不同Activity设置不同主题(或者其他更复杂的情况),它允许你在任何时候用代码动态修改APP的基础颜色配置。

例如:

//可以全局设置
public class SampleApp extends Application {    @Override    public void onCreate() {        super.onCreate();        Colorful.defaults()                .primaryColor(Colorful.ThemeColor.RED)                .accentColor(Colorful.ThemeColor.BLUE)                .translucent(false)                .dark(true);        Colorful.init(this);    }
}
//或者随便什么时候
Colorful.config(this)                .primaryColor(Colorful.ThemeColor.RED)                .accentColor(Colorful.ThemeColor.BLUE)                .translucent(false)                .dark(true)

               .apply();

public class MainActivity extends CActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setSupportActionBar(((Toolbar) findViewById(R.id.toolbar)));

        ColorPickerDialog dialog = new ColorPickerDialog(this);
        dialog.setOnColorSelectedListener(new ColorPickerDialog.OnColorSelectedListener() {
            @Override
            public void onColorSelected(Colorful.ThemeColor color) {
                //TODO: Do something with the color
            }
        });
        dialog.show();
    }
}

Preference Item

Colorful has a inbuilt preference item that will automatically set Colorful's colors.

Use colorpicker:primary_color and colorpicker:accent_color to tell Colorful which value to set.

        <org.polaric.colorful.ColorPickerPreference
            android:title="@string/primary_color"
            android:summary="@string/primary_color_desc"
            colorpicker:primary_color="true"/>

        <org.polaric.colorful.ColorPickerPreference
            android:title="@string/accent_color"
            android:summary="@string/accent_color_desc"
            colorpicker:accent_color="true"/>

Screenshots

ImageImage


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值