简体   繁体   中英

How to scale a Image of kivy toggle button and keep its aspect ratio?

Hej

I want to create my own radio button in kivy. For that I am using a template:

<myCheckBox@ToggleButton>:
    background_normal: 'gfx/cbActive.png'
    background_down: 'gfx/cbInactive.png'    
    background_disabled_down: 'gfx/cbActive.png'
    background_disabled_normal: 'gfx/cbInactive.png'

The button looks like:

按钮没有缩放

When using the template at the App it can be downscaled but the downscale process does not scale it symmetrically. It looks like:

坏的图像

Any ideas on why the downscaling isn't symmetrical?

The style for Button (and ToggleButton ) uses a BorderImage to scale the background. This allows the standard button-type images to be used appropriately. But you can easily disable this behavior by setting the border property used for scaling:

<myCheckBox@ToggleButton>:
    border: 0, 0, 0, 0
    background_normal: 'gfx/cbActive.png'
    background_down: 'gfx/cbInactive.png'    
    background_disabled_down: 'gfx/cbActive.png'
    background_disabled_normal: 'gfx/cbInactive.png'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM