Reputation: 337
I want to image be full. My code:
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.image import Image
from kivy.lang import Builder
Builder.load_string('''
<RootWidget>
FloatLayout:
Image:
id: imgh
pos: self.pos
size: self.size
source: 'background.gif'
''')
class RootWidget(FloatLayout):
def __init__(self, **kwargs):
pass
class TestApp(App):
def build(self):
return RootWidget()
if __name__ == '__main__':
TestApp().run()
But I cann't do it fullscreen, there are black lines on the right and on the left. How to fix it? I hope you help me...
Upvotes: 2
Views: 2226
Reputation: 1465
The black bars are propably because the image still keeps its ratio when you upscale it on the entire screen. One way of fixing it is to set allow_stretch to True and keep_ratio to False (within the kv string). Moreover I have set the size_hint to None and used the Window class to get the entire screen size. Just tested it with one of my images, hope it works for you as well.
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.image import Image
from kivy.lang import Builder
from kivy.core.window import Window
Builder.load_string('''
<RootWidget>
FloatLayout:
Image:
id: imgh
pos: self.pos
size_hint: None, None
size: root.size
allow_stretch: True
keep_ratio: False
source: 'background.gif'
''')
class RootWidget(FloatLayout):
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
class TestApp(App):
def build(self):
return RootWidget(size_hint=(None,None), size=Window.size)
if __name__ == '__main__':
TestApp().run()
Upvotes: 3