I've been trying to remove this bar (cant hotlink images, yet, check next link):
http://i.imgur.com/fRvMW.png
But I can't achieve it.
Tried the following:
Added into manifest the following:
android:theme="#android:style/Theme.NoActionBar"
But resulted as crash. Probably because I don't have this "Theme". I can't find out what should I write here.
Also tried to remove manually on each Fragment by Graphical Layout, selecting "No action bar", and it doesn't show up on the "preview" but it's shown in the app, probably because its the wrong place to configure it.
Note that it's with fragments. I searched about doing it by code, but I just found options to do it for activities.
So, my question is: How can I hide the App Action bar?
Edit:
SOLVED
On my code, I've this:
final ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
So, just added:
bar.hide();
And everything is working. Even if the tabs names aren't shown, the navigation still works (Swaping right and left for swapping fragments.)
Have you tried this?
ActionBar actionBar = getActionBar();
actionBar.hide();
Related
I have done practice adding menu on action bar. But for this case I have to add tab in actionbar (not below the actionbar) like below figure:
Please help me to find out the solution. Thanks in advance and sorry for bad English.
For your purpose you can try a simple stuff by creating custom ActionBar like this
You can create custom Action bar like this ..
// gets actionBar reference ..
actionBar = getSupportActionBar();
// This sets custom layout to action bar
actionBar.setCustomView(R.layout.action_provider);
// this is how... .... you get id of layout defined
iv_d = (ImageView) actionBar.getCustomView().findViewById(R.id.action_menu);
Now if you need to show stuff like ActionBar tabs then simply provide background on every layout where each layout contains a text and Image... This will provide a look n feel of ActionBar Tab over ActionBar.
Hope it clears your doubt. Let me know if still you have any concern in same.
Thanks.
I'm using Sliding Menu with ActionBarSherlock in my application. The actionbar and sliding menu works fine, but i want the sliding menu to slide only the content and not the actionbar like the latest version of youtube application.
Is this possible with slidingmenu? If yes, please tell how
Thanks in advance
Below is my code for actionbar and slidingmenu
getSlidingMenu().setSlidingEnabled(true);
getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
getSlidingMenu().setShadowDrawable(R.drawable.shadow);
getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
getSlidingMenu().setBehindScrollScale(0.25f);
getSlidingMenu().setFadeDegree(0.35f);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
Solution:
setSlidingActionBarEnabled(false);
Reference:
Have a look at example
your final code will look something like this after adding the suggested solution,
getSlidingMenu().setSlidingEnabled(true);
getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
getSlidingMenu().setShadowDrawable(R.drawable.shadow);
getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
getSlidingMenu().setBehindScrollScale(0.25f);
getSlidingMenu().setFadeDegree(0.35f);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
setSlidingActionBarEnabled(false);
I hope it will be helpful !!
According to the developer on GitHub:
Look at step 1. You have 2 options, SlidingMenu.SLIDING_WINDOW or SlidingMenu.SLIDING_CONTENT.
SLIDING_WINDOW will include the Title/ActionBar in the content section
of the SlidingMenu, while SLIDING_CONTENT does not.
I tried with the solution given . But it does not work.
I am using SherlockActionBar and SlidingMenu together.
It works good when I am not setting anything for setSlidingActionBarEnabled method. But it slides the whole window , I want to make it slide only when content is swiped.
So I called this method : setSlidingActionBarEnabled(false);
This has couple of issues :
This makes the app show a blank white page when it is loaded first. I have multiple tabs shown in action bar , so the first tab is shown as selected but the content is empty.
If I slide when say I am in tab 2 , then the back page (or behind page) content is visible but it also overlaps with what is shown currently on tab2.
Any pointers would be helpful.
EDIT: Android-Developers answer below explains solution very well
My problem is there are another bar, not exactly sure what it's name is - TitleBar? (The bar with the menu button and the white square logo) Above my ActionBar. What I ideally want is to merge my ActionBar with that bar or if not possible, implement my own bar completely amongst the tabs with icon and menu button. I have tried several things (see below image) and the rough code of how I am add the tabs is shown below as well.
Adding tabs to the ActionBar code:
actionBar = getActionBar(); // Get reference to ActionBar
// Add some navigation tabs...
// 1. Enable ActionBar navigation tabs
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
// 2. Add the tabs
Tab programTab = actionBar.newTab();
Tab settingsTab = actionBar.newTab();
Tab historyTab = actionBar.newTab();
programTab.setText("Program")
.setTabListener(new TabListener<Fragment_Program>(
this, "Program", Fragment_Program.class));
settingsTab.setText("Settings")
.setTabListener(new TabListener<Fragment_Settings>(
this, "Settings", Fragment_Settings.class));
historyTab.setText("History")
.setTabListener(new TabListener<Fragment_History>(
this, "History", Fragment_History.class));
actionBar.addTab(programTab);
actionBar.addTab(settingsTab);
actionBar.addTab(historyTab);
I was under the impression getActionBar() got reference to the existing bar which sits above my ActionBar in the screenshot.. that would be ideal.
Current application theme is android:theme="#android:style/Theme.Holo.Light.DarkActionBar"
Anyway, I have tried the following:
Various manifest changes including various .NoTitleBar combinations
requestWindowFeature(Window.FEATURE_NO_TITLE); after super.onCreate() and before setContentView()
The reason I am using standard ActionBar is this for a hardware device that will be running at least 4.0 and the version is highly unlikely to change.
Any thoughts?
Cheers
As I can understand you want to remove that view right?
The problem is that it your ActionBar. I guess you want to use Tabs, but without the ActionBar like many of the apps which are doing that. To achieve this use :
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowTitleEnabled(false);
bar.setDisplayShowHomeEnabled(false);
But don't forget something, if you want to achieve this, you should not inflate any menu in your Fragment / Activity :
#Override
public boolean onCreateOptionsMenu(Menu menu) {
//getSupportMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
You should see #ColorWP answer here
The Window flags are set already set inside super.onCreate(savedInstanceState); in which case you may want to use the following order of commands:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
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'm having serious problems getting tabs in actionbarsherlock below main action bar tabs to work in an app that runs from Android 2.2 up and looks like Android 4. (see link)
Tabs position
Have you tried running the official Demos app of ActionBar Sherlock? (https://github.com/downloads/JakeWharton/ActionBarSherlock/ActionBarSherlock-Sample-Demos-4.2.0.apk) It should contain a demo for the actionbar with Tabs.
If that works on Android 2.2 then you know the problem is in your code and you can check the Demos source code to see what you are doing differently (https://github.com/JakeWharton/ActionBarSherlock/tree/master/samples).
It's usual behavior of action bar (actionbarsherlock just simulate it). Use
ActionBar act = getSupportActionBar();
act.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.mytab_base_t));
to avoid white color in top bar (this option you can't access from any theme item yet). You can also monitor action bar height to change custom view of tabs on-fly, but you can't change action bar behavior, forget it. Otherwise please use PagerTitleStrip against action bar tabs.