android - 在搜索時(shí)如何隱藏底部BottomNavigationBar
問(wèn)題描述
當(dāng)點(diǎn)此搜索時(shí),底部的bottomNavigationBar會(huì)出現(xiàn),我想把它隱藏掉。
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);//設(shè)置隱藏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>
問(wèn)題解答
回答1:在搜索欄設(shè)置監(jiān)聽(tīng)事件,當(dāng)焦點(diǎn)在搜索欄的EditText時(shí),使用bottomNavigationBar.hide()隱藏BottomNavigationBar
回答2:我猜測(cè)題主想隱藏bottomNavigationBar的原因是鍵盤將它頂了上來(lái)吧,其實(shí)這個(gè)是不需要設(shè)置bar的隱藏的,在AndroidManifest.xml的對(duì)應(yīng)activity配置中,添加android:windowSoftInputMode='stateHidden | adjustPan'應(yīng)該就能解決這個(gè)問(wèn)題Android windowSoftInputMode 文檔
相關(guān)文章:
1. Span標(biāo)簽2. css - 求推薦適用于vue2的框架 像bootstrap這種類型的3. docker-machine添加一個(gè)已有的docker主機(jī)問(wèn)題4. docker images顯示的鏡像過(guò)多,狗眼被亮瞎了,怎么辦?5. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””6. SessionNotFoundException:會(huì)話ID為null。調(diào)用quit()后使用WebDriver嗎?(硒)7. java - Collections類里的swap函數(shù),源碼為什么要新定義一個(gè)final的List型變量l指向傳入的list?8. angular.js使用$resource服務(wù)把數(shù)據(jù)存入mongodb的問(wèn)題。9. redis啟動(dòng)有問(wèn)題?10. css - 關(guān)于div自適應(yīng)問(wèn)題,大家看圖吧,說(shuō)不清
