I want to make the back button in the action bar to look like this "<" and not arrow like "<-". Please let me know how to do it.
Asked
Active
Viewed 1,775 times
-1
-
Have you tried to use search? http://stackoverflow.com/questions/13259055/customize-android-action-bar?rq=1 – Ivan Pronin Apr 19 '17 at 19:08
-
duplicate: http://stackoverflow.com/a/9265774/5245903 – Veneet Reddy Apr 19 '17 at 19:09
-
what you have tried so far? post your java or xml code – Ferdous Ahamed Apr 19 '17 at 19:39
2 Answers
3
In you activity onCreate()
method do this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
........
................
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.icon_arrow);
..........
...................
}
OUTPUT:
For Icon:
If you are using Android Studio
, then you can easily add icons.
- Right click on drawable folder > New > Image Asset
- Choose icon type "Actionbar and Tab icons"
- Click on
Clip art
to choose your desired icon - Change theme as per your needs > Next
- Finish

Ferdous Ahamed
- 21,438
- 5
- 52
- 61
-
-
-
If you are using androidstudio, then you can easily add icons. Just right click on drawable folder > New > Image Asset > chosse icon type "actionbar and tab icons" > click on clip art to choose your desired icon > change theme as per your needs > next > finish – Ferdous Ahamed Apr 19 '17 at 19:58
-
if my answer helps to solve your problem then you should accept my answer and give an upvote. Please read http://stackoverflow.com/help/someone-answers – Ferdous Ahamed Apr 19 '17 at 20:10
-
If you don't mind Ferdous, I had another question in the forum. Can you answer it? – Rey Apr 19 '17 at 20:17
-
-
I have already answered your another question. please check my answer. Hope it will solve your problem properly. – Ferdous Ahamed Apr 19 '17 at 21:41
1
Fisrt make your YourXmlFile.xml like this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#ffff"
android:id="@+id/activity_viewsol"
tools:context=".viewsol">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Light"
android:fitsSystemWindows="true"
app:layout_collapseMode="pin"
android:elevation="5dp"
app:navigationIcon="@drawable/ic_back" //Arrow Back Icon
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</LinearLayout>
add this in YourFile.Java
Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top);
setSupportActionBar(toolbarTop);
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle("");
if(actionBar != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

Mouad Abdelghafour AitAli
- 350
- 2
- 12