10

I am getting this type of warning

@id/order_row_date can overlap @id/order_row_amout if @id/order_row_date grows due to localized text expansion.

If relative layout has text or button items aligned to left and right sides they can overlap each other due to localized text expansion unless they have mutual constraints like toEndOf/toStartOf.

My XML File is:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/order_row_lower_layout"
        android:layout_below="@+id/order_row_upper_layout"
        android:layout_toEndOf="@+id/order_row_box_layout"
        android:layout_toRightOf="@+id/order_row_box_layout"
        android:orientation="horizontal">

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/order_row_amout"
            style="@style/TextAppearance.AppCompat.Title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/spacing_normal"
            android:layout_marginRight="@dimen/spacing_normal"
            android:textColor="@color/color_gray"
            android:textStyle="bold"
            android:text="50000"
            tools:text="@string/string_amout_with_ruppe" />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/order_row_date"
            style="@style/TextAppearance.AppCompat.Subhead"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:textColor="@color/color_gray"
            tools:text="08/09/2016" />

</RelativeLayout>

Anyone Know about this type of warning?

Appreciated in Advance :)

Community
  • 1
  • 1
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437

2 Answers2

21

I have just changed width of first AppCompatTextView with match_parent and added following two lines:

android:layout_toLeftOf="@+id/order_row_date"
android:layout_toStartOf="@+id/order_row_date"

So Final XML:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/order_row_lower_layout"
    android:layout_below="@+id/order_row_upper_layout"
    android:layout_toEndOf="@+id/order_row_box_layout"
    android:layout_toRightOf="@+id/order_row_box_layout"
    android:orientation="horizontal">

    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/order_row_amout"
        style="@style/TextAppearance.AppCompat.Title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/spacing_normal"
        android:layout_marginRight="@dimen/spacing_normal"
        android:layout_toLeftOf="@+id/order_row_date"
        android:layout_toStartOf="@+id/order_row_date"
        android:textColor="@color/color_gray"
        android:textStyle="bold"
        android:text="50000"
        tools:text="@string/string_amout_with_ruppe" />

    <android.support.v7.widget.AppCompatTextView
        android:id="@+id/order_row_date"
        style="@style/TextAppearance.AppCompat.Subhead"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:textColor="@color/color_gray"
        tools:text="08/09/2016" />

</RelativeLayout>

Problem Solved in few Mins and It's very easy to understand.

May be helpful to others.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
0

I used constraint layout to solve this issue. With 0dp for both widths and applying margin as per requirements, Setting proper constraints, This issue won't aris at all.

BTW I got this issue while I was modifying someone's code after a long time.

Willey Hute
  • 939
  • 13
  • 18