更改 AlexaTextList 中单个列表项的颜色?

Change color of individual list items in AlexaTextList?

有没有办法为 AlexaTextList 中特定项目的文本指定颜色?在我的示例中,我想根据 lambda_handler 中的动态值来指定每个文本列表项是红色、黄色还是绿色。这是显示模板:

{
"type": "APL",
"version": "1.8",
"license": "Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0\nLicensed under the Amazon Software License  http://aws.amazon.com/asl/",
"theme": "dark",
"import": [
    {
        "name": "alexa-layouts",
        "version": "1.5.0"
    }
],
"mainTemplate": {
    "parameters": [
        "payload"
    ],
    "items": [
        {
            "type": "AlexaTextList",
            "headerTitle": "${payload.textListData.title}",
            "listItems": "${payload.textListData.listItems}",
            "secondaryText": "${payload.headlineTemplateData.properties.textContent.secondaryText.text}",
            "backgroundColor": "teal",
            "id": "covidList"
        }
    ]
}

}

你不能使用 AlexaTextList。

在 APL 上,所有组件都具有相同的 base properties
属性 之一称为 style,您可以应用带有颜色的样式,但 AlexaTextLists 不承认它。

{
    "redColor": {
        "values": [
            {
                "color": "red"
            }
        ]
    },
}

// in your components:
{ ... "style": "redColor", ... }

AlexaTextLists 包含 AlexaTextListItem 的列表,但也不承认它。
从今天开始,我建议您在需要更多灵活性时使用 Container 和 Text。

{
    "type": "APL",
    "version": "1.8",
    "license": "Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0\nLicensed under the Amazon Software License  http://aws.amazon.com/asl/",
    "theme": "dark",
    "import": [
        {
            "name": "alexa-layouts",
            "version": "1.5.0"
        }
    ],
    "mainTemplate": {
        "parameters": [
            "payload"
        ],
        "items": [
            {
                "type": "Container",
                "height": "100vh",
                "width": "100vw",
                "direction": "column",
                "alignItems": "center",
                "items": [
                    {
                        "type": "Text",
                        "color": "red",
                        "text": "Text in red"
                    },
                    {
                        "type": "Text",
                        "color": "blue",
                        "text": "Text in blue"
                    }
                ]
            }
        ]
    },
    "styles": {}
}