当点此搜索时,底部的bottomNavigationBar会出现,我想把它隐藏掉。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
//设置隐藏
bottomNavigationBar.isAutoHideEnabled();
bottomNavigationBar.setAutoHideEnabled(true);
bottomNavigationBar.setMode(BottomNavigationBar.MODE_SHIFTING);
.....
}

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在搜索栏设置监听事件,当焦点在搜索栏的EditText时,使用bottomNavigationBar.hide()隐藏BottomNavigationBar
我猜测题主想隐藏bottomNavigationBar的原因是键盘将它顶了上来吧,其实这个是不需要设置bar的隐藏的,在AndroidManifest.xml的对应activity配置中,添加android:windowSoftInputMode="stateHidden | adjustPan"应该就能解决这个问题
Android windowSoftInputMode 文档