9

I want to ask, working with two or more nested RelativeLayout. First code looks like picture 1, When I add android:layout_alignParentRight="true" in second RelativeLayout, this looks like picture 2. I want to align text right to second RelativeLayout. Where is my fault?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:background="@drawable/background"
        android:layout_height="wrap_content"
        android:id="@+id/testRL">
        <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:id="@+id/testRotateLL"
                android:background="@drawable/picture_border_offer_first_page">
                <TextView
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="7000TL"
                        android:textSize="15sp"
                        android:textColor="@android:color/white"
                        android:id="@+id/amountLayoutTV" />
        </RelativeLayout>
</RelativeLayout>

Picture 1:

Picture 1

And I add android:layout_alignParentRight="true"

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:background="@drawable/background"
    android:layout_height="wrap_content"
    android:id="@+id/testRL">
    <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:id="@+id/testRotateLL"
            android:background="@drawable/picture_border_offer_first_page">
            <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:text="7000TL"
                    android:layout_alignParentRight="true"
                    android:textSize="15sp"
                    android:textColor="@android:color/white"
                    android:id="@+id/amountLayoutTV" />
    </RelativeLayout>
</RelativeLayout>

Picture 2:

Picture 2

6
  • try to add to TextView android:layout_alignParentTop="true" Oct 12, 2011 at 11:38
  • worst-case scenario: Add ImageView before TextView instead of android:background="@drawable/picture_border_offer_first_page". They will overlay Oct 12, 2011 at 11:39
  • @first I tried alightTop, its same.
    – atasoyh
    Oct 12, 2011 at 11:44
  • @second. maybe, I can do it adding an imageview, but this is not my questions answer... (I will try)
    – atasoyh
    Oct 12, 2011 at 11:46
  • 1
    I had the same problem with a nested layout, took me several hours to find what causes it. Had to do with LinearLayouts and avoiding aligning with parent... there is a flaw somewhere in Android code I believe Dec 8, 2012 at 12:07

2 Answers 2

4

This question is unanswered. when I updated ADT version, this problem solved. There was a bug, I think.

I suggest you to check version of ADT sometimes...

1
  • 2
    also another tip, don't always update your ADT version! because newer versions come with newer bugs! you should always test the adt on another eclipse IDE.
    – meh
    Mar 19, 2013 at 15:42
0

In the first RelativeLayout you have:

android:layout_width="wrap_content"
android:layout_height="wrap_content"

You probably want:

android:layout_width="fill_parent"
android:layout_height="fill_parent"
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.