//点击设置主题按钮,弹出对话框,变换背景颜色
case R.id.them_img:
new ColorChooserDialog.Builder(getActivity(), R.string.theme)
.accentMode(true)//
.customColors(colors, null)//两个颜色数组
.dynamicButtonColor(false)//动态按钮颜色
.customButton(0)//设置颜色不显示
.cancelButton(R.string.cancel)
.show(getActivity());//传入上下文
break;
//定义设置主题颜色及样式的方法,然后在oncrate()方法里调用
//主题对话框弹出的样式
private void getColor() {
// colors you want to add,colors must not be null!!!
colors = new int[]{Color.YELLOW, Color.BLACK, Color.BLUE, Color.GRAY,
Color.GREEN, Color.CYAN, Color.RED, Color.DKGRAY, Color.LTGRAY, Color.MAGENTA,
Color.rgb(100, 22, 33), Color.rgb(82, 182, 2), Color.rgb(122, 32, 12), Color.rgb(82, 12, 2),
Color.rgb(89, 23, 200), Color.rgb(13, 222, 23), Color.rgb(222, 22, 2), Color.rgb(2, 22, 222)};
}