Android 在具有相同背景的多个视图上调用SetCompoundDrawableSwithinInstructBounds会导致大小不一致

Android 在具有相同背景的多个视图上调用SetCompoundDrawableSwithinInstructBounds会导致大小不一致,android,drawable,Android,Drawable,我有一个LinearLayout和两个EditText子代(不是直接子代)。我调用EditText.setcompoundDrawableswithintrisicBounds(0,0,R.drawable.xyz,0)在每个EditTexts的右侧放置一个可绘制(相同的可绘制)。这两个编辑文本完全相同,只是它们在列表视图中的顺序不同。但是,添加可绘制内容后,第一个EditText中可绘制内容的大小将大于第二个。具体地说,第一个EditText调整大小以适应可绘制文件的固有大小,而第二个Edit

我有一个
LinearLayout
和两个
EditText
子代(不是直接子代)。我调用
EditText.setcompoundDrawableswithintrisicBounds(0,0,R.drawable.xyz,0)
在每个
EditText
s的右侧放置一个可绘制(相同的可绘制)。这两个编辑文本完全相同,只是它们在
列表视图中的顺序不同。但是,添加可绘制内容后,第一个
EditText
中可绘制内容的大小将大于第二个。具体地说,第一个
EditText
调整大小以适应可绘制文件的固有大小,而第二个
EditText
则不调整大小(尽管它确实增长了一些小的数量)

为什么在两个几乎相同的视图中,两个相同的可绘图项显示的不同

此外,我还可以通过研究如何使可绘制文本不强制
编辑文本调整大小来解决这个问题。正如你所看到的,我已经遵循了关于制作背景比例的说明,但这似乎不起作用

守则:

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">

    <TextView 
        style="@style/fieldLabel"
        android:text="phone number"/>
    <EditText
        android:id="@+id/contactPhoneField" 
        android:inputType="phone"
        android:layout_width="fill_parent"
        style="@style/editableField"/>

</LinearLayout>

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">

    <TextView 
        style="@style/fieldLabel"
        android:text="e-mail address"/>
    <EditText
        android:id="@+id/contactEmailField" 
        android:inputType="textEmailAddress"
        android:layout_width="fill_parent"
        style="@style/editableField"/>

</LinearLayout>
此外,以后每次调用
EditText.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.xyz,0)
(第一次调用后)都会导致first
EditText
的大小在匹配第二个
EditText
和匹配可绘制大小之间切换

    <?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>

        <shape android:shape="rectangle">

            <gradient 
                android:startColor="#FFD060" 
                android:endColor="#FFBB33"
                android:angle="270"/>
            <padding android:left="5dp" android:top="5dp"
                android:right="5dp" android:bottom="5dp" />
            <corners android:radius="5dp" />
            <stroke android:width="2dp" android:color="#FF8800"/>
        </shape>

    </item>
    <item android:drawable="@drawable/warn"/><!-- a 35x35 px png which is taller than the native height of an EditText-->
</layer-list>
contactPhoneField.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.error_background, 0);
contactEmailField.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.error_background, 0);