問題描述
我有一個(gè) ListView,其中每個(gè)項(xiàng)目都有一個(gè) AsyncImage 和一個(gè)標(biāo)簽.加載圖像時(shí),它會顯示每個(gè)項(xiàng)目之間有間隙的布局.
I have a ListView that where each item has a AsyncImage and a Label. While the images load it shows the layout with gaps between each item.
-------
Item
-------
Item
-------
當(dāng)?shù)谝淮谓换グl(fā)生(發(fā)生滾動)時(shí),布局刷新并且間隙消失.
When the first interaction happens (a scroll occurs), the layout refreshes and the gaps disappear.
-------
Item
-------
Item
-------
我真的很想在圖像加載完成后刷新布局.如何刷新布局?
I'd really like to have the layout refresh when an image finishes loading. How do I refresh a layout?
推薦答案
通常你可以通過調(diào)用 widget.canvas.ask_update().
Usually you can ask the widget to update it's canvas by calling widget.canvas.ask_update().
對于布局,您可以嘗試通過調(diào)用 layout_instance.do_layout().
For a layout you could try triggering the layout of the widgets inside it by calling layout_instance.do_layout().
這篇關(guān)于Kivy 刷新布局(異步加載)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!