codenameone - Codenmae 一个如何在图标顶部添加预算并将它们放在工具栏中
问题描述
这是我试过的
notification = Command.create("", materialIcon(FontImage.MATERIAL_NOTIFICATIONS, 3, 0xffffff), evt -> {
////....
});
mainForm.getToolbar().addCommandToRightBar(notification);
我想在下面实现这一点
解决方案
标记任意按钮非常简单:https ://www.codenameone.com/blog/badging-arbitrary-components.html
Button chat = new Button("");
FontImage.setMaterialIcon(chat, FontImage.MATERIAL_CHAT, 7);
FloatingActionButton badge = FloatingActionButton.createBadge("33");
hi.add(badge.bindFabToContainer(chat, Component.RIGHT, Component.TOP));
工具栏按钮是封装的,不应该被标记。
要解决这个问题,请不要将命令添加到标题区域。相反,通过添加您自己的标题标签和任何您喜欢的样式的徽章按钮来创建一个完全自定义的标题区域。您可以通过使用setTitleComponent
而不是setTitle
和避免add*Command
这些按钮的方法来做到这一点。
推荐阅读
- google-sheets - 使用 Google 表格查询自动填充空白单元格
- elasticsearch - Kafka-connect弹性搜索索引的自动小写主题名称
- python - 如何读取 .CSV 文件的特定行/列并将它们存储为 numpy 矩阵?
- python - 在 numpy 中,如何创建一个复杂的矩阵?
- html - Angular6:在单个页面上的多个位置使用星级组件
- javascript - 故事书中的垂直滚动不准确
- meteor - 将本地 ReactionCommerce 应用程序与远程数据库连接
- php - 如何启用干净的网址?(VPS - Debian 9)
- javascript - 获取新对象的对象变量名
- c# - System.StackOverflowException,当获取设置属性时使用