安卓警告 : Grows due to localized text expansion

标签 android android-layout warnings android-relativelayout xml-layout

我收到这种类型的警告

@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.

我的 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="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>

有人知道这种类型的警告吗?

提前感谢:)

最佳答案

我刚刚用 match_parent 更改了第一个 AppCompatTextView 的宽度,并添加了以下两行:

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

所以最终的 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>

问题在几分钟内就解决了,而且非常容易理解。

可能对其他人有帮助。

关于安卓警告 : Grows due to localized text expansion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39996476/

相关文章:

java - 动态创建和添加框架布局android

php - "Notice: Undefined variable"、 "Notice: Undefined index"、 "Warning: Undefined array key"和 "Notice: Undefined offset"使用 PHP

JAVA - 保存Excel(Office 2010)而没有格式警告

java - 如何解决 com.google.gson.JsonException : java IllegalStateException :Expected BEGIN_OBJECT but was String at line 1 coulmn 10

android - MPAndroidChart 线图设置最多显示多少个 x 值

java - 无法解析 ArrayAdapter 的方法 super 参数

Android:访问传递给服务的变量

android - 获取 java.lang.ClassCastException : android. widget.FrameLayout$LayoutParams 无法转换为 android.widget.RelativeLayout$LayoutParams

java - 如何抑制findbugs中keySet迭代器而不是entrySet迭代器的低效使用?

Android:以编程方式在 FrameLayout 中设置边距 - 不起作用