Custom action bar title without icon when using tabs - android

I'm trying to set the color of my custom action bar from black to silver. The following images show what my app looks like at the moment. I'm trying to get rid of the black bar on the second image. I'm using the following code:
final ActionBar actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
actionBar.setCustomView(R.layout.action_bar);
Can anyone help me figure out what's wrong?

I'm trying to get rid of the black bar on the second image
change android:layout_marginLeft="-20dp" to android:layout_marginLeft="0dp"
Update:
this is your icon that you put so remove that:
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);

use this, this will solve ur problem
getActionBar().setDisplayShowCustomEnabled(true);
getActionBar().setCustomView(R.layout.demo);
getActionBar().setDisplayShowHomeEnabled(false);

I forgot that I left this question high and dry as I was in a hurry to finish this project. I ended up fixing the issue by using the AccentFragmentActivity.java. I had put in an issue here on Github. Since others weren't able to replicate this I think there was just some setting off that I couldn't locate, but if anyone runs to this in the future then maybe try using AccentFragmentActivity!

Related

Android: Can i add Tabs within actionBar?

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.

Android Split Action Bar Without Icon

My question is stupid I know, but i have no single idea how to solve that problem.
I followed Android API and perfectly made Split Action Bar, without problem.
http://developer.android.com/guide/topics/ui/actionbar.html#SplitBar
But when i decided to remove activity icon action bar drops down under the tabs and i can not find out why.
actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
//actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setTitle("Contacts");
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
After I remove comment (remove Icon respectivaly), tabs get up and bar gets down.

Changing android actionbar background not working

ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff")));
actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff")));
I'm trying to change my actionbar and the tab backgrounds, using the code above, the actionbar background changes perfectly but the tab backgrounds doesn't change at all, I'd like to know if this is due to the fact that I use supportActionBar or not, if anyone has a solution, Thanks!
it's easier to use it via xml.
have you tried out the next links:
https://developer.android.com/training/basics/actionbar/styling.html#CustomTabs
http://jgilfelt.github.io/android-actionbarstylegenerator/
?

Hide App name and it's bar

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();

Action Bar remove title and reclaim space

I am trying to remove the title from my action bar and reclaim the space it would otherwise consume for the use of menu items.
I have tried using a custom theme but so far nothing has worked. I have tried changing the text size to 0sp, changing the color to transparent, and setting visibility to gone.
I have also tried this :
ActionBar actionbar = getActionBar();
actionbar.setDisplayShowTitleEnabled(false);
I am targeting sdk 15+ and using the standard Android action bar (i.e. not Sherlock).
Thanks for any suggestions.
Here's what I'm talking about (the area bordered in red I want back):
Did you check out the ActionBar documentation yet? There's a method, setDisplayShowTitleEnabled(boolean) that does what you need.
Simply get a reference to your ActionBar, and call that with false:
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);

Categories

Resources