android - 在搜索时如何隐藏底部BottomNavigationBar
问题描述
当点此搜索时,底部的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);.....}
<?xml version='1.0' encoding='utf-8'?><LinearLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:tools='http://schemas.android.com/tools' android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical' android:clipChildren='false' tools:context='com.example.hp.smartclass.MainActivity'> <FrameLayoutandroid: android:layout_width='match_parent'android:layout_height='match_parent'android:layout_weight='1' /> <com.ashokvarma.bottomnavigation.BottomNavigationBarandroid: android:layout_width='match_parent'android:layout_height='wrap_content'android:layout_gravity='bottom'android:layout_weight='0' /></LinearLayout>

问题解答
回答1:在搜索栏设置监听事件,当焦点在搜索栏的EditText时,使用bottomNavigationBar.hide()隐藏BottomNavigationBar
回答2:我猜测题主想隐藏bottomNavigationBar的原因是键盘将它顶了上来吧,其实这个是不需要设置bar的隐藏的,在AndroidManifest.xml的对应activity配置中,添加android:windowSoftInputMode='stateHidden | adjustPan'应该就能解决这个问题Android windowSoftInputMode 文档
相关文章:
1. Docker for Mac 创建的dnsmasq容器连不上/不工作的问题2. javascript - vue的element-ui(饿了吗UI) webpack打包时externals无法分离3. 关于docker下的nginx压力测试4. docker-compose中volumes的问题5. docker gitlab 如何git clone?6. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?7. 如何解决Centos下Docker服务启动无响应,且输入docker命令无响应?8. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?9. 前端 - 类到底该如何去命名 .newsList 这种的命名难道真的不是过度语义化吗?~10. Hbuilder中的phpMyAdmin访问题

网公网安备