Reputation: 3887
Question is very simple but solution I have tried so many things. I want to Invisible the back button on the Action bar Not gone.
ActionBar actionBar = ((MainActivity) getActivity()).getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white);
I have tried this so far. But It actually remove the back-button from the Action bar. I want it to be just Invisible.
Upvotes: 1
Views: 1467
Reputation: 527
Hey android_griezmann
There is one very simple solution for it to use appBar layout and add it in yor layout and you can manage it as you want.
app_bar_layout
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/appTurquoiseColor">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageView
android:id="@+id/leftIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingRight="4dp"
android:src="@drawable/arrow"
android:visibility="invisible" />
<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/service_info"
android:gravity="left"
android:text="Toolbar Title"
android:textColor="@android:color/white"
android:textSize="22sp"
app:customTypeFace="dosis_book" />
<ImageView
android:id="@+id/service_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingRight="4dp"
android:src="@drawable/info"
android:visibility="gone" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</merge>
Upvotes: 1