Show Hide Sherlock Action Pane

I added Sherlock’s action bar to the action using the following line in the manifest:

android:theme="@style/Theme.Sherlock.Light" 

I want to save on the screen and hide the default action bar and show it only when the user clicks on the screen. I saw this in the Aldiko application, but I don’t know how to implement it.

Any help is appreciated.

+6
source share
2 answers

To hide the use below of your onCreate() action onCreate() ,

 getSupportActionBar().hide(); 

To show the use of the below code on a tap event,

 getSupportActionBar().show(); 

For more information, follow the ActionBarSherlock Usage .

+13
source

First specify the identifier of your packaging node activity layout (main_layout.xml):

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/containerMain" 

The second is implemented in your code for activity:

 boolean isActionBarShow=true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_layout); a=getSupportActionBar(); RelativeLayout rl= (RelativeLayout)findViewById(R.id.containerMain); rl.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction()==MotionEvent.ACTION_DOWN) if (isActionBarShow) { a.hide(); isActionBarShow=false; } else { a.show(); isActionBarShow=true; } return false; } }); 
+1
source

Source: https://habr.com/ru/post/947189/


All Articles