我试图使用ModalView
顶点指令为Canvas
绘制一个阴影。也就是说,ModalView
底部和左侧应该有一个轻微的阴影覆盖时,打开。我尝试过调用没有效果的ModalView
属性overlay_color
,而Canvas
Line
顶点指令没有创建正确的效果。但我似乎不能只画一条底部和左边的边框,这样会产生阴影的效果。
<PopScrollModal>
on_open: app.root._is_modal_open = True
on_dismiss: app.root._is_modal_open = False
id: popscroll
auto_dismiss: True
orientation: 'vertical'
size_hint: (0.94, 0.41)
border: [50, 50, 16, 16]
overlay_color: [0.1, 0.1, 0.1, 0.4]
pos_hint: {'top': 0.72}
background_normal: ''
background_color: (1, 1, 1, 0)
background: 'white.png'
canvas:
Color:
rgba: app.theme_cls.bg_dark
RoundedRectangle:
size: self.size
pos: self.pos
radius: [7,]
canvas.after:
Color:
rgba: (0.2, 0.2, 0.2, 0.4)
Line:
width: 1.
rounded_rectangle: (self.x, self.y, self.width, self.height, 7)
RecycleView:
id: view_popscroll
viewclass: 'PopScrollBut'
pos_hint: {'top': 1}
size_hint: [1, 0.99]
do_scroll_y: True
RecycleGridLayout:
cols: 1
spacing: 1
default_size: None, 70
default_size_hint: 1, None
size_hint: 1, None
size: self.minimum_size
这一行指令在底部绘制,但不坚持画布的半径:
canvas.after:
Color:
rgba: (0.2, 0.2, 0.2, 0.4)
Line:
width: 1.
close: False
points: self.pos[0], self.pos[1], self.pos[0] + self.size[0], self.pos[1]]
Line
指令只在ModalView
周围画一条线。有人能帮助理解如何设置Points
,使它们只出现在左边和底部,或者以相同的方式设置overlay_color
吗?
发布于 2020-09-22 03:23:29
您可以使用BorderImage
实现这一点。它没有得到很好的记录,很难理解它实际上是如何工作的。但这里有一个例子,主要是你想做的事:
class MyPop(Popup):
pass
kv = '''
<MyPop>:
canvas.before:
BorderImage:
source: 'shadow32.png'
border: 30, 0, 0, 30
pos: self.x - 30, self.y - 30
size: self.width + 60, self.height + 60
'''
下面是上面使用的shadow32.png
:
https://stackoverflow.com/questions/63977934
复制相似问题