Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the ID of the back arrow drawable in the ActionBar?

The following code causes a back arrow to appear in the ActionBar:

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

I'm looking for the resource ID of the arrow drawable, i.e. android.R.drawable.xxx. The reason I need this ID is so that I can manually set an identical arrow (size & colour) elsewhere in my app.

I tried making my own drawable and using that but the size was different from the one in the ActionBar.

like image 751
hmuss Avatar asked Jun 28 '17 16:06

hmuss


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 do I use Getupportactionbar?

To use the ActionBar utility methods, call the activity's getSupportActionBar() method. This method returns a reference to an appcompat ActionBar object. Once you have that reference, you can call any of the ActionBar methods to adjust the app bar. For example, to hide the app bar, call ActionBar.


1 Answers

If you have the support library in your project, you can make a back button in any place in your applicaction like this:

<ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="?attr/homeAsUpIndicator"
        android:background="?attr/selectableItemBackgroundBorderless"/>

Specifically the resource for the back arrow is ?attr/homeAsUpIndicator.

like image 51
VorteXavier Avatar answered Oct 11 '22 20:10

VorteXavier