python - KIVY: AsyncImage widget resizing issue within a RecycleView -
i'll start little contextualization before explaining issues.
i implemented recycleview widget contains recycleboxlayout default_size dynamic (based on parent's size). believe needed (i'm wrong) because app used on wide variety of devices , i'd rv contains average of 4 playlistitem. here code inside .kv file:
recycleview: id: rv scroll_type: ['bars', 'content'] scroll_wheel_distance: dp(114) viewclass: 'playlistitem' recycleboxlayout: default_size: none, (self.parent.height / 4 - dp(80)) if self.parent.height / 4 > dp(60) else dp(60) default_size_hint: 1, none size_hint_y: none height: self.minimum_height orientation: 'vertical' spacing: dp(20) padding: dp(20)
now let's take @ code playlistitem viewclass:
<playlistitem@boxlayout>: created_time: '' description: '' id: '' image_url: '' name: '' owner: '' updated_time: '' playlist_name: '' mdcard: asyncimage: size_hint_x: .2 size: self.texture_size source: root.image_url mipmap: true boxlayout: orientation:'vertical' mdlabel: text: root.playlist_name theme_text_color: 'secondary' font_style:'title' mdseparator: height: dp(1) mdlabel: text: 'body' theme_text_color: 'primary'
so, i'd keep ratio of image inside asyncimage widget. i'd image's width take 20% of parent widget. , i'd asyncimage's size equal image's (texture) size. code above depending on window's size, image's height not equal parent's height (the result not pretty uh). when try:
asyncimage: size_hint_y: none height: self.parent.height source: root.image_url mipmap: true
the image's height (equal mdcard height) asyncimage's width can become large. here's picture better understand:
the workaround can think is:
<playlistitem@boxlayout>: created_time: '' description: '' id: '' image_url: '' name: '' owner: '' updated_time: '' playlist_name: '' # added # <---------------------------------- size_hint_y: none miminum_height: self.minimum_height mdcard: asyncimage: size_hint_x: .2 size: self.texture_size source: root.image_url mipmap: true
this not working. believe @ time of init texture has not loaded yet, self.minimum_height none. i'm not sure that. hope help.
bonus detail: know sure raw images have 480px height
thanks lot attention , sorry long post.
atis on #kivy irc channel found solution. 1 should use image_ratio!:
asyncimage: size_hint: none,none size:self.image_ratio*root.height,root.height source: root.image_url mipmap: true
Comments
Post a Comment