BottomNavigationView 去掉菜单长按 弹出菜单文字吐司,去掉水波纹
方法1
//去掉长按吐司
val bottomNavView: View = bottomNavigationView.getChildAt(0)
bottomNavView.findViewById<View>(R.id.action_home).setOnLongClickListener { true }
bottomNavView.findViewById<View>(R.id.action_room).setOnLongClickListener { true }
bottomNavView.findViewById<View>(R.id.action_device).setOnLongClickListener { true }
bottomNavView.findViewById<View>(R.id.action_smart).setOnLongClickListener { true }
bottomNavView.findViewById<View>(R.id.action_personal).setOnLongClickListener { true }
方法2
private fun initBottomNavigationView() {
val ids = ArrayList<Int>()
ids.add(R.id.action_home)
ids.add(R.id.action_room)
ids.add(R.id.action_device)
ids.add(R.id.action_smart)
ids.add(R.id.action_personal)
clearToast(bottomNav,ids);
}
private fun clearToast(bottomNavigationView:BottomNavigationView, ids: ArrayList<Int>) {
val bottomNavigationMenuView = bottomNavigationView.getChildAt(0) as ViewGroup
//遍历子View,重写长按点击事件
for (position in 0 until ids.size){
bottomNavigationMenuView.getChildAt(position).findViewById<View>(ids[position]).setOnLongClickListener { true }
}
}
去掉点击水波效果
app:itemBackground设置背景颜色为白色
app:itemBackground="@color/white"
浙公网安备 33010602011771号