How to add separator between logo and button in custom bar

346 Views Asked by At

I am trying to have divider between my logo and button in custom bar. Can anyone suggest what is ideal way to do...I tried it didn't work

![enter image description here][1]

XML

    <RelativeLayout
        android:id="@+id/title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/windowtitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="#0a2436"
            android:gravity="center_horizontal|center_vertical"
            android:paddingBottom="10dip"
            android:paddingTop="10dip"
            android:src="@drawable/logo">
        </ImageView>

        <ImageButton
            android:id="@+id/syncbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginTop="3dip"
            android:background="@android:color/transparent"
            android:gravity="center"
            android:text="Sync"
            android:src="@drawable/sync"/>

    </RelativeLayout>


</RelativeLayout>
1

There are 1 best solutions below

0
On

Try this:

<RelativeLayout
    android:id="@+id/title"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/windowtitle"
        android:layout_width="wrap_content" <!--changed-->
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#0a2436"
        android:gravity="center_horizontal|center_vertical"
        android:paddingBottom="10dip"
        android:paddingTop="10dip"
        android:src="@drawable/logo" />

    <View
        id="@+id/separator"
        width="1dp"
        height="match_parent"
        background="@android:color/white" <!--for example-->
        toRightOf="@id/windowtitle"
    />

    <ImageButton
        android:id="@+id/syncbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginTop="3dip"
        android:background="@android:color/transparent"
        android:gravity="center"
        android:text="Sync"
        android:src="@drawable/sync"
        toRightOf="@id/separator" />

</RelativeLayout>