Colorful是一个动态主题库,允许您很容易地改变App的配色方案
[img]http://dl2.iteye.com/upload/attachment/0122/2283/0cb8582c-e1e4-3fd8-b644-08b09f70d504.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0122/2285/5967ad99-96c2-3b5f-a17c-3e752368f1b2.png[/img]
在Application中初始化Colorful
如果你想设置默认的主题色,可以使用defaults()
当然你也可以随时改变主题,只要调用一下apply()即可:
想使用主题,还得让你的Activity继承CActivity:
Colorful内置了一个ColorPickerDialog,可以直接设置主题:
Colorful还内置了一个preference可以自动设置主题
用colorpicker:primary_color & colorpicker:accent_color告诉Colorful设置哪个颜色。
github
https://github.com/garretyoder/Colorful
[img]http://dl2.iteye.com/upload/attachment/0122/2283/0cb8582c-e1e4-3fd8-b644-08b09f70d504.png[/img]
[img]http://dl2.iteye.com/upload/attachment/0122/2285/5967ad99-96c2-3b5f-a17c-3e752368f1b2.png[/img]
在Application中初始化Colorful
public class SampleApp extends Application {
@Override
public void onCreate() {
super.onCreate();
Colorful.init(this);
}
}
如果你想设置默认的主题色,可以使用defaults()
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);
}
}
当然你也可以随时改变主题,只要调用一下apply()即可:
Colorful.config(this)
.primaryColor(Colorful.ThemeColor.RED)
.accentColor(Colorful.ThemeColor.BLUE)
.translucent(false)
.dark(true)
.apply();
想使用主题,还得让你的Activity继承CActivity:
public class MainActivity extends CActivity
Colorful内置了一个ColorPickerDialog,可以直接设置主题:
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();
}
}
Colorful还内置了一个preference可以自动设置主题
用colorpicker:primary_color & colorpicker:accent_color告诉Colorful设置哪个颜色。
<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"/>
github
https://github.com/garretyoder/Colorful