0

我有一个 ImageView 对象,我正在设置 android:src="@drawable/some_xml_file" 而不是标准 png 并且它似乎并不总是呈现可绘制对象,正如您在此处的第一行中看到的那样(它也间歇性地发生在其他行中):替代文字 http://www.freeimagehosting.net/uploads/d09b549a9d.jpg

我试过设置 src 和背景属性,但它们都有相同的效果。我的列表视图行项目的源代码是这样的:

<ImageView android:id="@id/action_button" android:background="@drawable/action_box"
    android:layout_width="25dip" android:layout_height="25dip" 
    android:layout_alignParentRight="true" android:layout_marginTop="10dip" />

那么我的 res/drawable/action_box.xml 是这样的:

<?xml version="1.0" encoding="UTF-8"?>

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
       <gradient

            android:startColor="#81c557"
            android:endColor="#539942" 
            android:angle="270"/>
        <stroke android:width="1dip"  android:color="#a8d78a"  />

4

1 回答 1

0

我确实解决了这个问题,这个问题与 getView() 方法中的条件有关。我基本上学到了当你设置可见性/宽度等时,你应该始终明确地处理所有情况。

于 2010-08-05T18:05:17.057 回答