You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Android底部导航栏点击背景及长按提示文本?

移除底部导航栏点击高亮与长按提示的方法

一、移除点击时的图标/文本背景效果

如果使用的是Android平台的BottomNavigationView,可以通过以下两种方式处理:

  • 布局文件配置:给BottomNavigationView添加属性 app:itemBackground="@null",直接取消点击时的背景高亮效果。
  • 代码动态设置:在Activity/Fragment中调用代码:
bottomNavigationView.setItemBackgroundResource(0);

二、移除长按提示文本

方法1:拦截长按事件

遍历导航栏的所有菜单项,给每个项设置长按监听器并拦截事件,阻止提示文本弹出:

BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
for (int i = 0; i < bottomNavigationView.getMenu().size(); i++) {
    MenuItem menuItem = bottomNavigationView.getMenu().getItem(i);
    View itemView = bottomNavigationView.findViewById(menuItem.getItemId());
    if (itemView != null) {
        itemView.setOnLongClickListener(v -> true);
    }
}

方法2:通过自定义样式禁用提示

在styles.xml中定义专属样式:

<style name="NoTooltipBottomNav" parent="Widget.MaterialComponents.BottomNavigationView">
    <item name="android:tooltipText">@null</item>
</style>

然后在布局文件中给BottomNavigationView应用该样式:

<com.google.android.material.bottomnavigation.BottomNavigationView
    ...
    style="@style/NoTooltipBottomNav"
    ... />

内容的提问来源于stack exchange,提问作者C-Gian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 17:01:21