Badge#
#
Added in version 2.0.0.
See also
Badges show notifications, counts, or status information on navigation items and icons.
Example#
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
MDScreen:
md_bg_color: self.theme_cls.backgroundColor
MDIcon:
icon: "gmail"
pos_hint: {'center_x': .5, 'center_y': .5}
MDBadge:
text: "12"
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
from kivymd.app import MDApp
from kivymd.uix.badge import MDBadge
from kivymd.uix.label import MDIcon
from kivymd.uix.screen import MDScreen
class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return (
MDScreen(
MDIcon(
MDBadge(
text="12",
),
icon="gmail",
pos_hint={'center_x': 0.5, 'center_y': 0.5},
),
md_bg_color=self.theme_cls.backgroundColor,
)
)
Example().run()