I am trying to create an app and use a toast to show a message, but when the toast is displayed the background changes to a darker color (see image below). Is there a way to disable this, so just the toast is displayed without a fade animation.
Note that I installed kivy with pip, I typed: pip install https://github.com/kivy/kivy/archive/master.zip
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.toast import toast
KV = '''
BoxLayout:
orientation:'vertical'
MDToolbar:
id: toolbar
title: 'Test Toast'
md_bg_color: app.theme_cls.primary_color
left_action_items: [['menu', lambda x: '']]
FloatLayout:
MDRaisedButton:
text: 'TEST KIVY TOAST'
on_release: app.show_toast()
pos_hint: {'center_x': .5, 'center_y': .5}
'''
class Test(MDApp):
def show_toast(self):
'''Displays a toast on the screen.'''
toast('Test Kivy Toast')
def build(self):
return Builder.load_string(KV)
Test().run()
The fade in and fade out are hard wired characteristics of
Toast
. There is no way to change that. However, you can create your own version of that class by extendingToast
, something like this:I haven't tested this code, but this should give you the idea of how to approach this. Also, note that if this app ends up as an Android App, then the above code will not be used, but the actual Android Toast would be used.