Android CalendarView选择器背景

时间:2016-10-14 16:37:27

标签: android xml calendarview

我有一个CalendarView对象,我想从XML更改圆圈的背景。 我读到我必须实现自己的对象来完成这个简单的任务。如何在不实现自己的情况下轻松完成此任务? I would like to change the circle's color

1 个答案:

答案 0 :(得分:1)

在styles.xml中添加新样式

pane.setOnMouseClicked(evt -> {
    Circle circle = ...

    pane.getChildren().add(circle);

    circle.setOnMouseClicked(event -> {
        event.consume();
        // TODO: circle specific event handling
    });
});

然后在打开DatePickerDialog时以这种方式传递

<style name="MyCalanderTheme" parent="AppTheme">
    <item name="colorAccent">@color/SetYourColorHere</item>
</style>

将SetYourColorHere替换为您要设置为日期背景的任何颜色

或者你也可以设置主要样式accentColor ...但是如果你想为app accentColor和数据背景使用不同的颜色,那么按照上面的方法。