Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Warning : Grows due to localized text expansion

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 :)

like image 901
Pratik Butani Avatar asked Oct 12 '16 10:10

Pratik Butani


1 Answers

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.

like image 74
Pratik Butani Avatar answered Oct 02 '22 11:10

Pratik Butani