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.
Related
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);
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")));
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
Actually I have this hamburger icon in my navigation drawer auto generated by eclipse:
I would get this result:
First thing, always show what you have tried resolve your query.
Second to answer this, try
ActionBar actionBar = getSupportActionBar();
actionBar.setLogo(R.drawable.ic_launcher);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
place this in your widget
android:drawableRight="#drawable/image"
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