• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Input tag doesn't override android:layout_toRightOf

Fluf puf

Lurker
I have a couple of textswitcher's that are very similar so I wanted to reuse them (the same with a TextField, but I gonna use the textswitcher as example). The views are being used in a RelativeLayout.

The textswitcher is defined in a separate xml file:

Code:
<TextSwitcher xmlns:android="no_url_allowed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
</TextSwitcher>

and then I would include it as:

Code:
<include android:id="@+id/test" android:layout_toRightOf="@id/hoursMinutesSeparatorTextField" layout="@layout/clock_visual"/>

If needed the whole mainactivity:
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="url_not_allowed"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp">

    <TextSwitcher
        android:id="@+id/hoursTextSwitcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true">
    </TextSwitcher>

    <TextView 
        android:id="@+id/hoursMinutesSeparatorTextField"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=":"
        android:layout_toRightOf="@id/hoursTextSwitcher"
        android:textSize="36dp" >
    </TextView>

    [COLOR="Red"]<include android:id="@+id/test" android:layout_toRightOf="@id/hoursMinutesSeparatorTextField" layout="@layout/clock_visual"/>[/COLOR]
        
</RelativeLayout>

A tutorial said that you can override every android:layout_* attribute in the include tag. So I want to reuse the textswitcher a couple of times, and as such the id and the android:layout_toRightOf will change so I override it.

Now the weird thing is that it doesn't override the android:layout_toRightOf part. It does however work with the id. And when I for example do the same but with the following textswitcher:

Code:
<TextSwitcher xmlns:android="no_url_allowed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/hoursMinutesSeparatorTextField" >
</TextSwitcher>

Than it still doesn't override but it will lay the component out accordingly but always to the hoursTextSwitcher instead of the one I defined in my input tag.

So is it normal that the android:layout_toRightOf doesn't get overriden? And if so is there another way to reuse this component?
 
Back
Top Bottom