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. python小白 關于類里面的方法獲取變量失敗的問題2. thinkPHP5中獲取數據庫數據后默認選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙3. linux運維 - python遠程控制windows如何實現4. Python2中code.co_kwonlyargcount的等效寫法5. javascript - 如何用最快的速度C#或Python開發一個桌面應用程序來訪問我的網站?6. django - Python error: [Errno 99] Cannot assign requested address7. mysql數據庫做關聯一般用id還是用戶名8. [python2]local variable referenced before assignment問題9. 求救一下,用新版的phpstudy,數據庫過段時間會消失是什么情況?10. python小白,關于函數問題
