Reputation: 2933
First I know this is a duplicate question, but none of the answers solved my issue.
Here is my current code:
final ActionBar actionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.action_bar);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_horizontal"
android:layout_gravity="fill_horizontal"
android:padding="0dp"
android:layout_margin="0dp"
android:background="@color/article_background">
<ImageButton android:src="@drawable/filter"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="#00000000"
android:scaleType="centerInside"
android:id="@+id/filters"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<ImageView
android:src="@drawable/tc_logo"
android:layout_width="36dp"
android:layout_height="36dp"
android:scaleType="centerInside"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/logo" />
<ImageButton android:src="@drawable/menu_button"
android:background="#00000000"
android:layout_width="36dp"
android:layout_height="36dp"
android:scaleType="centerInside"
android:id="@+id/options"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"/>
</LinearLayout>
And there is a left padding showing.
I tried the following suggestions from Stack Overflow:
I tried setting a custom actionbar style in themes with zero padding.
I tried with relative and linear layout as the custom layout.
I tried setting custom actionbar icon in themes and enabling onHomeUp to display a one px image..
I tried layout gravity and gravity to fill_horizontal but didn't work.
No matter what I do, it still shows up.
Upvotes: 2
Views: 2307
Reputation: 1044
I had the same issue, and nothing helped, until I found this SO question.
setDisplayHomeAsUpEnabled(true)
. <item name="android:homeAsUpIndicator">@null</item>
. This will cause the up to disappear, but the padding the icon had will be gone. Upvotes: 1