'how to add MDCard in ScrollView in KivyMD?
I am new to KivyMD and I have this doubt. How to add an MDCard in ScrollView, just like how we do with lists. Is it possible to do that or not. I referred to a lot of online solutions and websites but none of the questions are related to my question. Please somebody help
Solution 1:[1]
I know this question is old, I came across this while searching for some other answer, I will leave the solution here just in case anyone needs it.
MDCards as of now can't be added to ScrollView as it is.
To make a scrollable list of cards, you will have to define a custom class, study the following code:
<CardItem@RelativeLayout>
size_hint_y: None
height: '150dp'
radius: 50
# for use in ScrollView
MDCard:
size_hint: .9, .9
pos_hint: {'center_x': .5}
Image:
source: 'images/sample1.png'
# you can make these cards as complex as you like
Now
ScrollView:
MDList:
CardItem
CardItem:
size_hint: .9, .9
pos_hint: {'center_x': .5}
Image:
source: 'images/sample2.png'
Note that, the properties defined can be overwritten and new properties can be added as well.
Hope this answers your question!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Strange |
