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. 为什么我ping不通我的docker容器呢???2. angular.js - angular内容过长展开收起效果3. dockerfile - 为什么docker容器启动不了?4. javascript - 能否让vue-cli的express修改express重启服务5. PHP类中的$this6. javascript - 想要用Ajax 即时返回XML 中的数据,前后端怎么选择?7. mysql - 用Cron Jobs備份數據庫?8. docker gitlab 如何git clone?9. node.js - 急急急!node request如何获取响应中cookie的值呢?10. javascript - jQuery中live事件在移动微信端下没有效果;代码如下

网公网安备