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. macOS Sierra 10.12 安裝mysql 5.7.1出現錯誤2. mysql主主同步,從庫不同步應該怎么解決?3. javascript - 按鈕鏈接到另一個網址 怎么通過百度統計計算按鈕的點擊數量4. android - 安卓做前端,PHP做后臺服務器 有什么需要注意的?5. mysql 獲取時間函數unix_timestamp 問題?6. mysql - 拖拽重排序后怎么插入數據庫?7. mysql - 僅僅只是把單引號與反斜杠轉義不用prepare statement能否避免sql注入?8. 新入手layuiadmin,部署到tp中。想用php自已寫一個后臺管理系統。9. mysql在限制條件下篩選某列數據相同的值10. php - 生產環境下,給MySQL添加索引,修改表結構操作,如何才能讓線上業務不受影響?
