Reputation: 161
I am using an image inside a BoxLayout of which size_hint_y
is set to None
And the images seems to have no response to any attempt to change the size,
And i suspect that the issue arises only on using size_hint_y:None
It works fine if i remove the size_hint_y parameter, but doing so will affect the other widgets positioning , so how can i do this without avoiding the size_hint_y:None
Parameter
Code
from kivy.app import App
from kivy.lang import Builder
Kv=("""
BoxLayout:
orientation:'vertical'
size_hint_y:None
height:self.minimum_height
spacing:5
BoxLayout:
orientation:'vertical'
size_hint_y:None
height:self.minimum_height
spacing:20
Image:
size_hint:None,None
source:"/storage/3666-3432/Download/Lion.jpg"
""")
class MyApp(App):
def build(self):
return Builder.load_string(Kv)
MyApp().run()
Edit
from kivy.app import App
from kivy.lang import Builder
Kv=("""
ScrollView:
BoxLayout:
orientation:'vertical'
size_hint_y:None
height:self.minimum_height
spacing:5
BoxLayout:
orientation:'vertical'
size_hint_y:None
height:self.minimum_height
spacing:20
Image:
height:2000
size_hint:None,None
source:"/storage/3666-3432/Download/Lion.jpg"
""")
class MyApp(App):
def build(self):
return Builder.load_string(Kv)
MyApp().run()
In the above code you can see that when the height parameter is used, the image size dosen't change and rather a huge space is being created at the either sides of the image
Upvotes: 0
Views: 149
Reputation: 38857
You are setting the Image
height
to 2000, and so the Image
widget will have a height
of 2000. The width
of the Image
will be the default value of 100 because you are not setting that value and size_hint_x
is None
for the Image
. However, by default, the Image
widget has allow_stretch
of False
and keep_ratio
of True
, so the texture will be 100 wide and an appropriately ratioed height (not 2000).
I'm not entirely sure what you are attempting to accomplish, but if you want the Image
to stretch, you should add allow_stretch: True
to the Image
and either add a width
for the Image
, or change size_hint:None,None
to size_hint:1,None
.
Upvotes: 1