Search code examples
pythonpython-3.xkivyscrollviewkivymd

Why my image is on the toolbar not below it in kivy?


I can't just figure it out why my image is on the toolbar not below it. I have tried many attempts like changing the height etc etc but it didn't worked for me. Can anyone help me out to get the right code for this one please Piece of my code :

from kivy.lang import Builder
from kivymd.app import MDApp
from kivy.uix.screenmanager import Screen
from kivy.core.window import Window
Window.size = (360 , 640)
kv = '''
#:import get_color_from_hex kivy.utils.get_color_from_hex
ScreenManager:
    Second:
<Second>:
    name: 'second'
    MDToolbar:
        id :toolbar
        title: "..."
        elevation: 10
        specific_text_color: get_color_from_hex('#FCF6F5FF')
        pos_hint: {'top':1.0}
        md_bg_color: get_color_from_hex('#822057FF')
    ScrollView:
        MDBoxLayout:
            size_hint: 1,None
            adaptive_height: True
            height: root.height-toolbar.height
            orientation:'vertical'
            AsyncImage:
                source: 'national.jpg'
            MDLabel:
                halign:'center'
                md_bg_color:get_color_from_hex('#FCF6F5FF')
                text: 'National Digital Library of India (NDLI) is a virtual repository of learning resources which is not just a repository with search/browse facilities but provides a host of services for the learner community. It is sponsored and mentored by Ministry of Education, Government of India, through its National Mission on Education through Information and Communication Technology (NMEICT). Filtered and federated searching is employed to facilitate focused searching so that learners can find the right resource with least effort and in minimum time. NDLI provides user group-specific services such as Examination Preparatory for School and College students and job aspirants. '
'''
class Second(Screen):
    pass
class Test(MDApp):
    def build(self):
        self.root = Builder.load_string(kv)
Test().run()

Thanks for Help!!


Solution

  • Finally find a solution using Layouts as shown in below code:

    from kivy.lang import Builder
    from kivymd.app import MDApp
    from kivy.uix.screenmanager import Screen
    from kivy.core.window import Window
    Window.size = (360, 640)
    kv = '''
    #:import get_color_from_hex kivy.utils.get_color_from_hex
    ScreenManager:
        Second:
    <Second>:
        name: 'second'
        MDBoxLayout:
            orientation:'vertical'
            MDToolbar:
                id :toolbar
                title: "..."
                elevation: 10
                specific_text_color: get_color_from_hex('#FCF6F5FF')
                pos_hint: {'top':1.0}
                md_bg_color: get_color_from_hex('#822057FF')
            ScrollView:
                MDBoxLayout:
                    size_hint: 1,None
                    adaptive_height: True
                    height: 500
                    orientation:'vertical'
                    AsyncImage:
                        source: 'national.jpg'
                    MDLabel:
                        halign:'center'
                        md_bg_color:get_color_from_hex('#FCF6F5FF')
                        text: 'National Digital Library of India (NDLI) is a virtual repository of learning resources which is not just a repository with search/browse facilities but provides a host of services for the learner community. It is sponsored and mentored by Ministry of Education, Government of India, through its National Mission on Education through Information and Communication Technology (NMEICT). Filtered and federated searching is employed to facilitate focused searching so that learners can find the right resource with least effort and in minimum time. NDLI provides user group-specific services such as Examination Preparatory for School and College students and job aspirants. '
    '''
    
    
    class Second(Screen):
        pass
    
    
    class Test(MDApp):
        def build(self):
            self.root = Builder.load_string(kv)
    
    
    Test().run()