有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何为列表项动态设置boder颜色?

我有一个列表视图,里面有RelativeLayout元素。我想根据项目的数据为每个项目的右边框设置不同的颜色。我知道我可能需要这样的东西来创建边界:

<layer-list xmlns:安卓="http://schemas.安卓.com/apk/res/安卓">
    <item>
        <shape 安卓:shape="rectangle">
            <stroke 安卓:width="2dp" 安卓:height="2dp"
                安卓:color="#FF0000" />
            <solid 安卓:color="#000000" />
            <padding 安卓:left="1dp" 安卓:top="1dp" 安卓:right="1dp"
                安卓:bottom="1dp" />

            <corners 安卓:radius="1dp" 安卓:bottomRightRadius="5dp"
                安卓:bottomLeftRadius="0dp" 安卓:topLeftRadius="5dp"
                安卓:topRightRadius="0dp" />
        </shape>
    </item>

</layer-list>

但我不知道如何为每个元素设置颜色


共 (1) 个答案