2013-03-10 44 views

回答

14

只是hide()

getActionBar().hide(); 
當你想隱藏它,並使用 show()

getActionBar().show() 

當你想證明這一點。就是這樣。

請記住,如果您使用的是View.SYSTEM_UI_FLAG_FULLSCREEN,則無法正常工作。

+0

感謝如何ü可以將其隱藏,當你按下任何地方屏幕上? – ymerdrengene 2013-03-10 20:40:45

+0

@ymerdrengene覆蓋onTouch() – 2013-03-10 20:41:08

+0

@RaghavSood調用show()/ hide()被調用時存在延遲。這可以避免嗎? – Ammar 2014-04-15 06:51:43

1

試試這個。你在這裏調用隱藏或顯示方法,並根據您的建議

public class AbstractActivity Activity { 

    private boolean showActions = false; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     ActionBar bar = getSupportActionBar(); 
     if (bar != null) { 
     bar.setHomeButtonEnabled(true); 
     bar.setDisplayShowHomeEnabled(true); 
     } 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     return super.onCreateOptionsMenu(menu); 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     int id = item.getItemId(); 
     switch (id) { 
     case android.R.id.home: 

     return true; 
     default: 
     // Nothing to do here 
     return super.onOptionsItemSelected(item); 
     } 
    } 

    private void handleActionBarTitle(boolean show) { 
     ActionBar actionBar = getSupportActionBar(); 
     if (actionBar == null) { 
     return; 
     } 
     actionBar.setDisplayShowTitleEnabled(show); 
    } 


    protected void disableActions() { 
     this.showActions = false; 
    } 

    protected void enableActions() { 
     this.showActions = true; 
    } 

    protected void hideActionBarTitle() { 
     handleActionBarTitle(false); 
    } 

    protected boolean showActions() { 
     return showActions; 
    } 

    protected void showActionTitle() { 
     handleActionBarTitle(true); 
    } 

您的活動可能只需要擴展了這個AbstractActivity你的答案:)但是

+0

我想我的問題還不清楚。如果你可以去「fullscrean-mode」,而不是顯示/隱藏操作欄,我會發現如何去做。 – ymerdrengene 2013-04-03 17:53:45

相關問題