hide up button and show icon as home in action bar - android

actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(true);
i have this code to hide title and up button in my code and show only the icon but my problem is when i click on the icon it doesnt work anymore meaning it does not bring me to home activity anymore but when i set actionBar.setDisplayHomeAsUpEnabled(false); to true it works ok any idea on how to make this work the way i want it to work

Related

ActionBar icon is not showing if setDisplayHomeEnabled is false

I want to set icon on ActionBar.
So when I have setDisplayShowHomeEnabled set to true icon shows, when false - nothing. I don't want show back button on actionBar, only icon.
What's the problem?
actionBar.setTitle("");
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setIcon(getResources().getDrawable(R.drawable.logo_big));
for back button write this code:
actionbar.setDisplayShowHomeEnabled(true);
actionbar.setDisplayHomeAsUpEnable(false);
its byDefault false though, but in your case if its showing then you have to false programatically.
you have to use getSupportActionBar()instead of actionbar() object.

Remove default home/up button in action mode

I have created custom action mode which visible on long click on list item . There is default back/up button visible in actionMode.
Without change in style.xml , it's possible to remove default action mode back/up button from fragment/activity class.
Kindly help.
Try this,
getActionBar().setDisplayHomeAsUpEnabled(false);
OR
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
this may helps you.
Use the method: getActionBar().setDisplayHomeAsUpEnabled(false) to remove the home button from the action bar.
Example:
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
}
You can remove action button home up enabled through ::
if you are using support v7 lib then
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
else
getActionBar().setDisplayHomeAsUpEnabled(false);

Android - invisible ActionBar with back button

I know how to implment ActionBar with back button. But I want to make ActionBar invisible or with no background, I want to have only visible back button arrow. Is it possible?
With a little of search you will find the response. Any way you can try this :
ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));
If you want to have your tab background below your ActionBar add this too :
actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));

Add image to left side of action bar ?

I need add a image in between navigation button and drop-down in action-bar.How can I do this?
you need to call setIcon() it will change the icon
getActionBar();
ActionBar actionBar = getActionBar();
actionBar.setIcon(R.drawable.my_icon);
see this for more detail

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.

Categories

Resources