0

I'm trying to customize my Action Bar view and I defined my own one. The problem is it doesn't correctly fill the Action Bar. Actual look

I would like the left lens to be completely on the left, but I can't! Here's my Layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    >
<ImageView
    android:id="@+id/iv_logo"
    android:layout_width="325dip"
    android:layout_height="50dip"
    android:layout_centerInParent="true"
    android:contentDescription="@string/app_name"
    android:clickable="true"
    android:src="@drawable/logo"
    android:onClick="home_click" />

<ImageView
    android:id="@+id/burger"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_margin="0dp"
    android:background="@null"
    android:src="@drawable/lente" />

<ImageView
    android:id="@+id/imageButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_margin="15dp"
    android:layout_marginEnd="25dp"
    android:layout_marginRight="25dp"
    android:background="@null"
    android:src="@drawable/lente" />

user1868607
  • 357
  • 4
  • 11

1 Answers1

0

Instead of giving fixed width/height to the central view, configure it in such a way that it stretches completely between the left and the right image-views. I haven't tested the following code but it should render the views the way I have described.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    >


<ImageView
    android:id="@+id/burger"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_margin="0dp"
    android:background="@null"
    android:src="@drawable/lente" />

<ImageView
    android:id="@+id/imageButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_margin="15dp"
    android:layout_marginEnd="25dp"
    android:layout_marginRight="25dp"
    android:background="@null"
    android:src="@drawable/lente" />

<ImageView
    android:id="@+id/iv_logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:contentDescription="@string/app_name"
    android:clickable="true"
    android:layout_toRightOf="@id/burger"
    android:layout_toLeftOf="@id/imageButton"
    android:src="@drawable/logo"
    android:scaleType="center"
    android:onClick="home_click" />
</RelativeLayout>

If that still doesn't solve the problem, it could be one of the following issues:

  1. The image itself has left padding i.e. it has some blank space on its left.
  2. This Layout is enclosed in a parent layout which has some left margin/padding.
Varun Singh
  • 1,135
  • 13
  • 18
  • Doesn't work yet, it still has some space on the left.The image doesn't have blank space on its left, I don't know what to say about the parent layout because it is the ActionBar one! – user1868607 Mar 15 '15 at 16:14
  • If I were at your place I would confirm it by 1) using a different image to test; 2) removing the other two images and only keeping this one there. If it still is the same then its intended to be that way. – Varun Singh Mar 15 '15 at 16:19