I have this activity made with actionBarSherlock. Is it possible to hide title of activity (not only text but the title bar) I tried:
getSupportActionBar().hide();
but it hides tabs too.
Picture:
https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-prn1/q71/1017267_10200157522600680_915484448_n.jpg
1.You must call setNavigationMode(NAVIGATION_MODE_TABS) to make the tabs visible
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
2.You must disable the activity title by calling setDisplayShowTitleEnabled(false)
getSupportActionBar().setDisplayShowTitleEnabled(false);
3.You must disable application home affordance by calling setDisplayShowHomeEnabled(false)
getSupportActionBar().setDisplayShowHomeEnabled(false);
This way should able to able to get a look like this in your activity.
try one of these possibly?
add this to the manifest file under application:
android:theme="#android:style/Theme.NoTitleBar"
or in your activity:
ActionBar actionBar = getActionBar();
actionBar.hide();
getActionBar().setDisplayOptions(Window.FEATURE_NO_TITLE);
It worked for me hope it will help you out.
And this will give result like this
Related
I have an activity in my app, which is using swipeable tabs with action bar
For example :-
this tutorial
So my question is to add action bar to my activity and remove titlbar
similar question
I'm unsure as to exactly what you class as a title bar but you could do this in XML by putting the following in your Android Manifest for a particular activity to remove your title bar.
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen
Add this to your activity before calling setContentView();
this.requestWindowFeature(Window.FEATURE_ACTION_BAR | Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
if that dosen't work try this
//use this to disable the icon from ActionBar
getActionBar().setDisplayShowHomeEnabled(false);
//use this to disable the application name from ActionBar
getActionBar().setDisplayShowTitleEnabled(false);
Use this code in oncreate() method of activity before adding content:
getWindow().requestFeature(Window.FEATURE_NO_TITLE)
I am having difficulties trying to remove the back/home button from the action bar.
getActionBar().setDisplayShowHomeEnabled(false); //disable back button
getActionBar().setHomeButtonEnabled(false);
In a older android phone, the back button is removed with these two code lines. However with the nexus 4, the back button still appears but is just disabled. Also I am just adding a menu item on the right that behaves like the back/home button replacing the back/home button. What am I missing?
Use getActionBar().setDisplayHomeAsUpEnabled(false) to remove the home button from the action bar.
If you're on API level 14 or above and are not using ActionbarSherlock, this code in onCreateOptionsMenu will disable the up button, remove the left caret, and remove the icon:
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(false); // disable the button
actionBar.setDisplayHomeAsUpEnabled(false); // remove the left caret
actionBar.setDisplayShowHomeEnabled(false); // remove the icon
}
source: https://stackoverflow.com/a/24967862/2887103
ElectronicGeeks answer is correct.
For API lower than 11, Use:
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
To control the up affordance, use setDisplayHomeAsUpEnabled().
None of the suggested solutions works for me.
But this one does:
// Hide the back button
mActionBar.setHomeAsUpIndicator(null);
It is a kind of a hack (last resort solution), though, so showing the action bar again means setting its icon back again.
This worked for me :)
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
For Kotlin;
(activity as AppCompatActivity).supportActionBar?.setDisplayHomeAsUpEnable(false)
In the case where you have used toolbar as Action bar:-
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Use the below code to hide the navigation button:-
toolbar.setNavigationIcon(null);
This code work for me
For remove navigation bar
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
For remove status bar
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
ฺBut above code, it show again when you touch on screen, so if you want static state, combine this code.
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE);
You can use this code :
toggle.setDrawerIndicatorEnabled(false);
Works great for me.
I am trying to use the ui option: splitActionBarWhenNarrow in my application, but it seems as I am experiencing an unwanted behaviour.
EDIT: Attaching a small gist with some more code.
This is the code in the manifest for the activity:
<activity
android:name="com.example.HomeActivity"
android:uiOptions="splitActionBarWhenNarrow"
android:label="#string/app_name" >
That is the only activity I intent to change the ActionBar style on. In the activity code, I have disabled the actionBar title and icon, so the tabs can merge as the only top action bar.
private void setupActionBar() {
final ActionBar mActionBar = getActionBar();
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_one).setTabListener(this));
mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_two).setTabListener(this));
mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_three).setTabListener(this));
}
This worked well; however, it seems as if the bottom action bar is not going all the way to the bottom of the activity, but rather just below the top action bar.
Here is what it looks like after the code I wrote, How can I get it to go all the way down, like for instance on the Android's stock messaging app?
Edit, reattaching images.
Here's how it currently look with the code above, and here's how I want it to look.
I have posted a working demo app with tabs and an actiobar at the buttom
Here
Check it out and hope it helps
I am using ActionBarSherlock on my simple app and would like to hide the HOME button if the user is on the home/main activity. I understand how to do so with the setHomeButtonEnabled(false), however, I am extending a class that contains my navigation and has setHomeButtonEnabled(true) and I cannot seem to overwrite that setting in my main activity.
Thanks to #andy I am able to get rid of the icon, however, I cannot get rid of the < arrow. Any ideas?
Thanks for any help.
With ActionBarSherlock just put this in your home/main activity onCreate() method:
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
The only way I have found to do this is to not have this set on your baseActivity:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
and then set it as you will for each activity that requires the menu:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
or
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
Get the home button view and apply this
mHomeButton.setVisibility(View.INVISIBLE);
I want to remove the back icon and the application icon from the Actionbar. I am using ActionBarSherlock. I have seen many applications that dont show an application icon or a back button ? Is this the best implementation ?
Kind Regards,
I think by "back" button you mean up button that is used to navigate up the application's structural hierarchy. Anyway hope this piece of code solves your problem if you don't want to keep the app icon on top.
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true); // if you want to show title on Actionbar
the action bar doesn't have a back button since all android devices should include a back button in some way or another.
what you probably mean is the up button , which should go to the "home page" of the app.
you don't have to use it . it's just a nice thing to have. use setDisplayHomeAsUpEnabled for showing and hiding it .