当我通过Asset Studio中的图像资产创建操作栏图标时,即使原始图像是彩色的,该图标也始终只有一种颜色。
我在another post中发现了icons are defined by Android to use only one color
,但
Android默认的可绘制资源为多种颜色,例如@android:drawable / ic_menu_delete
那我该如何创建一个自定义的彩色图标呢?为什么我不能这样做?
答案 0 :(得分:0)
如果您使用彩色图标,请尝试以编程方式使用
holiday_in_project = fields.Text('Holiday in project', compute='get_holiday')
# get holiday include in interval date project
@api.depends('date_start', 'date')
def get_holiday(self):
if self.resource_calendar_id:
for leave_ids in self.env['resource.calendar.leaves'].search([
('calendar_id', '=', self.resource_calendar_id.name),
]):
# datetime to date
date_from = leave_ids.date_from.date()
date_to = leave_ids.date_to.date()
Range = namedtuple('Range', ['start', 'end'])
r1 = Range(start=self.date_start, end=self.date)
r2 = Range(start=date_from, end=date_to)
latest_start = max(r1.start, r2.start)
earliest_end = min(r1.end, r2.end)
overlap = (earliest_end - latest_start).days + 1
overlapping_dates = []
if overlap > 0:
overlapping_dates = range(latest_start.toordinal(), earliest_end.toordinal() + 1)
overlapping_dates = [date.fromordinal(x) for x in overlapping_dates]
# print('overlapping_dates')
# print(overlapping_dates)
self.holiday_in_project = overlapping_dates
# reconvert text to liste (if need)
liste = self.holiday_in_project.split(',')
print(liste)
其中view_action_bar是xml上的视图ID