【问题标题】:How to remove the toast like popup in BottomNavigationView when long press the item?长按项目时如何在BottomNavigationView中删除类似弹出的吐司?
【发布时间】:2022-07-22 16:50:19
【问题描述】:

如何去除材料底部导航视图BottomNavigationView长按单个项目时弹出的toast样。下面附上演示图片

【问题讨论】:

    标签: android kotlin popup bottomnavigationview material-components-android


    【解决方案1】:

    tooltip,可以通过在每个菜单项上调用TooltipCompat.setTooltipText(view, null)来禁用它。

    bottomNavigationView
        .menu.forEach {
                TooltipCompat.setTooltipText(bottomNavigationView.findViewById<View>(it.itemId), null)
            }
    

    当您将bottomNavigationView 设置为null 后将其设置为tooltip 文本时,上述代码可能无法正常工作。您可以覆盖菜单项本身的longClickListener,因此它不会显示tooltip 文本。

    bottomNavigationView
        .menu.forEach {
            bottomNavigationView.findViewById<View>(it.itemId).setOnLongClickListener {
                // add any code which you want to execute on long click
                true
                }
        }
    

    【讨论】:

    • 不工作。长按时仍然显示工具提示
    • @SumanRadhakrishnan 我已经更新了我的答案。
    • 谢谢,您的解决方案运行良好。非常感谢
    【解决方案2】:

    不工作接受的答案@Praveen

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-14
      • 2014-05-13
      • 2020-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多