0

I was wanted to put one divider just next to "RefreshButton" and in between Logo and Refresh Button. Below is my code...How shall i add that ? Is it possible in Relative Layout or will i have to change my layout to Linear ?

Wanting divider image like 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="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>

        <ImageView>DIVIDER</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:src="@drawable/sync"/>

    </RelativeLayout>
user45678
  • 1,504
  • 6
  • 29
  • 58

2 Answers2

0

put this Imageview as your divider in your layout.

 <ImageView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:src="@android:drawable/divider_horizontal_dark"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitXY"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:paddingBottom="2dp"
            android:paddingTop="2dp" />

or

<View
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray"/>

refer this link

Community
  • 1
  • 1
Nambi
  • 11,944
  • 3
  • 37
  • 49
0

You can do it in both ways, but to do it with a relative layout, you need to use the layout_toRightOf attribute:

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

    <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_vertical"
        android:paddingBottom="10dip"
        android:paddingTop="10dip"
        android:src="@drawable/logo" >
    </ImageView>

    <ImageView
        android:id="@+id/divider"
        android:layout_toRightOf="@id/windowtitle">DIVIDER</ImageView>

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

</RelativeLayout>

Keep in mind that you need to have an ID for your divider image for this to work.

npace
  • 4,218
  • 1
  • 25
  • 35