Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing left arrow from the actionbar in android?

Tags:

I want to remove the left arrow from the action bar and only icon and title needed.

My code:

getSupportActionBar().setIcon(R.drawable.logo); getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setTitle(R.string.dashboardtitle); getSupportActionBar().setDisplayHomeAsUpEnabled(false); 

But this doesn't remove the left arrow . Any help!!

like image 674
info Avatar asked May 27 '13 10:05

info


People also ask

How do I get rid of the back arrow on my android toolbar?

getActionBar(). setDisplayShowHomeEnabled(false); //disable back button getActionBar(). setHomeButtonEnabled(false); In a older android phone, the back button is removed with these two code lines.

How can I customize my action bar in android?

This example demonstrate about how to create a custom action bar in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How can remove action bar from single activity in android?

If we want to remove the ActionBar only from specific activities, we can create a child theme with the AppTheme as it's parent, set windowActionBar to false and windowNoTitle to true and then apply this theme on an activity level by using the android:theme attribute in the AndroidManifest. xml file.

How do I remove the action bar?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme. AppCompat.


2 Answers

According to specification android specification: To enable the icon for up navigation (which displays the "up" indicator next to the icon), call setDisplayHomeAsUpEnabled(true) on your ActionBar:

protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);      setContentView(R.layout.main);     ActionBar actionBar = getActionBar();     actionBar.setDisplayHomeAsUpEnabled(true);     ... } 

So you should set actionBar.setDisplayHomeAsUpEnabled(false);

UPDATE: I test next code with ActionBar sherlock and it's work. There is no back arrow:

getSupportActionBar().setIcon(R.drawable.ic_launcher); getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setTitle(R.string.about_event_location); getSupportActionBar().setDisplayHomeAsUpEnabled(false); 
like image 106
Borys Avatar answered Oct 24 '22 23:10

Borys


You need to add this to your actionBar theme. You can replace arrow image with your own image which can be transparent

<item name="android:homeAsUpIndicator">@drawable/action_arrow</item> 
like image 27
vivek Avatar answered Oct 24 '22 22:10

vivek