1

This is the relative layout part of my layout:

<RelativeLayout
    android:id="@+id/headLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/headbg"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/head2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:paddingLeft="@dimen/d10dp"
        android:text="@string/archive"
        android:textColor="@color/white"
        android:textSize="@dimen/d20sp" />

    <ImageView
        android:id="@+id/moreBtn"
        android:layout_width="@dimen/d50sp"
        android:layout_height="@dimen/d30sp"
        android:layout_alignParentEnd="true"
        android:layout_gravity="center_vertical"
        android:paddingRight="@dimen/d10dp"
        android:scaleType="centerInside"
        android:src="@drawable/show_btn" />
</RelativeLayout>

On an avd that has api 19, it works perfectly. Textview is on the left end of the relative layout, while the imageview is on the right. But on an avd that has api 14, both are on the left end. Am i missing some tags for alighparentend to work or it just doesn't work on api 14?

rds
  • 26,253
  • 19
  • 107
  • 134
Lendl Leyba
  • 2,287
  • 3
  • 34
  • 49
  • Can you post your resulting layout? – AlvaroSantisteban Jun 19 '14 at 18:18
  • if you know the end is on the right (for example an English only app) use `layout_alignParentRight` or for right to left languages use `layout_alignParentLeft` for multi language apps you could apply the correct setting problematically – CrandellWS Oct 27 '15 at 22:52

2 Answers2

3

The reason is simply because according to the documentation, android:layout_alignParentEnd was introduced in Api level 17.

Source:

http://developer.android.com/reference/android/R.attr.html#layout_alignParentEnd

0

As already answered layout_alignParentEnd is only supported since API 17. Before, it should be ignored, but can cause crashes on certain devices. You should define a default style and override it for v17.

Another, more hacky approach is to use the fitStyle of image:

<ImageView
    android:id="@+id/moreBtn"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="..."
    android:paddingLeft="@dimen/d10dp"
    android:paddingRight="@dimen/d10dp"
    android:scaleType="fitEnd"
    android:src="@drawable/show_btn" />
rds
  • 26,253
  • 19
  • 107
  • 134