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:在搜索欄設置監(jiān)聽事件,當焦點在搜索欄的EditText時,使用bottomNavigationBar.hide()隱藏BottomNavigationBar
回答2:我猜測題主想隱藏bottomNavigationBar的原因是鍵盤將它頂了上來吧,其實這個是不需要設置bar的隱藏的,在AndroidManifest.xml的對應activity配置中,添加android:windowSoftInputMode='stateHidden | adjustPan'應該就能解決這個問題Android windowSoftInputMode 文檔
相關文章:
1. html5 - ElementUI table中el-table-column怎么設置百分比顯示。2. python - 使用readlines()方法讀取文件內容后,再用for循環(huán)遍歷文件與變量匹配時出現疑難?3. 對mysql某個字段監(jiān)控的功能4. css3 - less或者scss 顏色計算的知識應該怎么學?或者在哪里學?5. 注冊賬戶文字不能左右分離6. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能7. css - 網頁div區(qū)塊 像蘋果一樣可左右滑動 手機與電腦8. javascript - 數組的過濾和渲染9. html - vue項目中用到了elementUI問題10. JavaScript事件
