【发布时间】:2021-04-04 08:49:22
【问题描述】:
我是 Kivy 的新手,我正在尝试使用 kivy 和滚动视图。 我需要停止按钮背景图像的拉伸,我希望按钮看起来像第一张图像。我正在使用 background_normal 将背景图像添加到按钮。我需要更改网格布局中的 row_default_height: root.height*0.3 吗?还是在每个按钮上添加图像高度和宽度?如何阻止图像调整大小?
任何帮助都会很好,谢谢:)
我的 .kv 文件
#: import FadeTransition kivy.uix.screenmanager.FadeTransition
#: import GridLayout kivy.uix.gridlayout
#: import BoxLayout kivy.uix.boxlayout
#: import ButtonBehavior kivy.uix.button
#: import Image kivy.uix.image
#: import Window kivy.core.window.Window
ScreenManager:
transition: FadeTransition()
MainScreen:
AnotherScreen:
<MainScreen>:
name: "main"
BoxLayout:
ScrollView:
GridLayout:
some_property: setattr(Window, 'fullscreen' , 'auto') or 'real_value!'
id: container_y
size_hint_y: None
cols: 2
row_default_height: root.height*0.3
height: self.minimum_height
Image:
source: "teaflav/Crushes.png"
Button:
background_normal: 'teaflav/Crushes.png'
on_release: app.root.current ="other"
height: 40
Button:
background_normal: 'teaflav/Crushes.png'
on_release: app.root.current ="other"
height: 40
Button:
background_normal: 'teaflav/Crushes.png'
on_release: app.root.current ="other"
height: 40
Button:
background_normal: 'teaflav/Crushes.png'
on_release: app.root.current ="other"
height: 40
Button:
background_normal: 'teaflav/Crushes.png'
on_release: app.root.current ="other"
height: 40
【问题讨论】:
标签: python kivy scrollview