Genry
Genry

Reputation: 1408

Android: <include> overrides are not affecting the layout

I have the following layout buttons.xml

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/buttonsLayout" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:screenOrientation="portrait">

    <ImageView android:id="@+id/imgLeftArrow"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignParentLeft="true" android:layout_marginLeft="@dimen/standard_margin"
        android:contentDescription="@string/pic_arrow_left"
        android:background="@drawable/arrow_left" />

    <ImageView android:id="@+id/imgUpArrow" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_centerHorizontal="true"
        android:contentDescription="@string/pic_arrow_up" android:background="@drawable/arrow_up" />

    <ImageView android:id="@+id/imgRightArrow"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignParentRight="true" android:layout_marginRight="@dimen/standard_margin"
        android:contentDescription="@string/pic_arrow_right"
        android:background="@drawable/arrow_right" />

</RelativeLayout>

And I have main.xml layout:

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

    <include
        android:layout_alignParentBottom="true"
        layout="@layout/buttons" />

</RelativeLayout>

As you can see, I am overriding the buttons.xml layout to be at the bottom of this one. But the problem is, that the layout is shown on top, and not on the bottom. If I set this property directly inside the RelativeLayout in buttons.xml, it is shown on bottom.

What is the problem? According to android documentation http://developer.android.com/resources/articles/layout-tricks-reuse.html I can override the properties of the included layout.

Upvotes: 0

Views: 187

Answers (1)

Samir Mangroliya
Samir Mangroliya

Reputation: 40416

<RelativeLayout android:id="@+id/belowlayout"
        android:layout_marginBottom="2dp"  
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
        <include layout="@layout/mybottomlayout" />
    </RelativeLayout>

Upvotes: 1

Related Questions