Search code examples
androidalignmentandroid-relativelayout

android : align in relative layout


I have some problem with my relative layout

code :

<?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="50dp"
    android:background="@drawable/round_corners_filter" >

        <TextView
                android:id="@+id/filter_city_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/filter_name"
                android:textSize="17sp"
                android:layout_centerVertical="true"
                android:paddingLeft="13dp"
                android:text="CCCC" /> 



        <ImageView 
                android:id="@+id/filter_city_row"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentRight="true"
                android:layout_marginRight="15dp"
                android:layout_marginLeft="15dp"
                android:src="@drawable/app_icon"/>

        <TextView
                android:id="@+id/filter_city_value"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/filter_value"
                android:textSize="17sp"
                android:layout_centerVertical="true"
                android:layout_alignRight="@id/filter_city_row" 
                android:text="DDDDDDDDDD" /> 


</RelativeLayout>

i have this : enter image description here

i need filter_city_value to align right to filter_city_row. but it align right to the right side of image, but i need to the left, i need the filter_city_value goes after image filter_city_row..


Solution

  • Switch this:

    android:layout_alignRight="@id/filter_city_row"
    

    To this:

    android:layout_toLeftOf="@id/filter_city_row"
    

    This will place @id/filter_city_value to the left of @id/filter_city_row, which should be what you're looking for.