android - 在搜索時(shí)如何隱藏底部BottomNavigationBar
問題描述
當(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>
問題解答
回答1:在搜索欄設(shè)置監(jiān)聽事件,當(dāng)焦點(diǎn)在搜索欄的EditText時(shí),使用bottomNavigationBar.hide()隱藏BottomNavigationBar
回答2:我猜測題主想隱藏bottomNavigationBar的原因是鍵盤將它頂了上來吧,其實(shí)這個(gè)是不需要設(shè)置bar的隱藏的,在AndroidManifest.xml的對應(yīng)activity配置中,添加android:windowSoftInputMode='stateHidden | adjustPan'應(yīng)該就能解決這個(gè)問題Android windowSoftInputMode 文檔
相關(guān)文章:
1. javascript - ie11以下單擊打開不了file,雙擊可以。求解?2. javascript - 關(guān)于定時(shí)器 與 防止連續(xù)點(diǎn)擊 問題3. javascript - 關(guān)于這組數(shù)據(jù)如何實(shí)現(xiàn) 按字母列表分類展示 不改動(dòng)數(shù)據(jù)結(jié)構(gòu)4. javascript - 寫移動(dòng)端的頁面的時(shí)候,有不一快空白,是怎么回事?5. javascript - 求助這種功能有什么好點(diǎn)的插件?6. objective-c - ios百度地圖定位問題7. 微信開放平臺(tái) - Android調(diào)用微信分享不顯示8. html5 - rudy編譯sass的時(shí)候有中文報(bào)錯(cuò)9. javascript - 在IE中(9+)平時(shí)的樣式不生效,只有用開發(fā)者工具選中這個(gè)元素才生效,是什么原因?10. Python做掃描,發(fā)包速度實(shí)在是太慢了,有優(yōu)化的方案嗎?
