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. node.js - 在vuejs-templates/webpack中dev-server.js里为什么要exports readyPromise?2. html - 移动端radio无法选中3. css3 - transition属性当鼠标一开的时候设置的时间不起作用4. apache - 怎么给localhost后面默认加上8080端口5. 前端 - html5 audio不能播放6. Java中call by value和call by reference的区别7. css - 关于伪类背景问题8. CSS3 border凹陷该如何编写?9. html5 - 如何实现图中的刻度渐变效果?10. mysql - 数据库建字段,默认值空和empty string有什么区别 110
