FitImage#

Feature to automatically crop a Kivy image to fit your layout Write by Benedikt Zwölfer

Referene - https://gist.github.com/benni12er/95a45eb168fc33a4fcd2d545af692dad

Example:#

MDBoxLayout:
    size_hint_y: None
    height: "200dp"
    orientation: 'vertical'

    FitImage:
        size_hint_y: 3
        source: 'images/img1.jpg'

    FitImage:
        size_hint_y: 1
        source: 'images/img2.jpg'

Example with round corners:#

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/fitimage-round-corners.png
from kivy.lang import Builder

from kivymd.app import MDApp

KV = '''
MDScreen:

    MDCard:
        radius: 36
        md_bg_color: "grey"
        pos_hint: {"center_x": .5, "center_y": .5}
        size_hint: .4, .8

        FitImage:
            source: "bg.jpg"
            size_hint_y: .35
            pos_hint: {"top": 1}
            radius: 36, 36, 0, 0
'''


class Example(MDApp):
    def build(self):
        self.theme_cls.theme_style = "Dark"
        return Builder.load_string(KV)


Example().run()

API - kivymd.uix.fitimage.fitimage#

class kivymd.uix.fitimage.fitimage.FitImage(**kwargs)#

Box layout class. For more information, see in the BoxLayout class documentation.

source#

Filename/source of your image.

source is a StringProperty and defaults to None.

mipmap#

Indicate if you want OpenGL mipmapping to be applied to the texture. Read Mipmapping for more information.

New in version 1.0.0.

mipmap is a BooleanProperty and defaults to False.

reload(self)#