-1

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.

Rey
  • 71
  • 9

2 Answers2

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:

enter image description here

For Icon:

If you are using Android Studio, then you can easily add icons.

  1. Right click on drawable folder > New > Image Asset
  2. Choose icon type "Actionbar and Tab icons"
  3. Click on Clip art to choose your desired icon
  4. Change theme as per your needs > Next
  5. Finish

enter image description here

Ferdous Ahamed
  • 21,438
  • 5
  • 52
  • 61
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);

Output : enter image description here