android - 在搜索時如何隱藏底部BottomNavigationBar
問題描述
當(dāng)點(diǎn)此搜索時,底部的bottomNavigationBar會出現(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>
問題解答
回答1:在搜索欄設(shè)置監(jiān)聽事件,當(dāng)焦點(diǎn)在搜索欄的EditText時,使用bottomNavigationBar.hide()隱藏BottomNavigationBar
回答2:我猜測題主想隱藏bottomNavigationBar的原因是鍵盤將它頂了上來吧,其實這個是不需要設(shè)置bar的隱藏的,在AndroidManifest.xml的對應(yīng)activity配置中,添加android:windowSoftInputMode='stateHidden | adjustPan'應(yīng)該就能解決這個問題Android windowSoftInputMode 文檔
相關(guān)文章:
1. MySQL的聯(lián)合查詢[union]有什么實際的用處2. 數(shù)組排序,并把排序后的值存入到新數(shù)組中3. mysql 遠(yuǎn)程連接出錯10060,我已經(jīng)設(shè)置了任意主機(jī)了。。。4. 網(wǎng)頁爬蟲 - python 爬取網(wǎng)站 并解析非json內(nèi)容5. 默認(rèn)輸出類型為json,如何輸出html6. python的正則怎么同時匹配兩個不同結(jié)果?7. mysql怎么表示兩個字段的差8. win10 python3.5 matplotlib使用報錯9. PHP訂單派單系統(tǒng)10. php多任務(wù)倒計時求助
