1

我正在尝试使用 TeamsMessagingExtensionsSearch 的 C# .NET Core 代码在 MS Teams 中显示自适应卡。

我想知道如何更改自适应卡的背景颜色,以及是否有办法更改按钮 (OpenURL) 的颜色和外观以及 TextBlock 中的字体类型。我已经阅读过有关使用 setHostConfig 执行此操作的信息,但我不确定我可以在代码中的哪个位置进行设置。

我尝试使用更改卡中显示的背景颜色"backgroundImage": "https://www.beautycolorcode.com/abcdef.png" ,这会更改背景颜色,但是当我将卡粘贴到消息中时,我看到有一个顶部标题,其中包含添加到卡中的应用程序名称和应用程序图标(来自 App Manifest)以白色背景显示。我为我的 backgroundImage 和 manifest.json 指定了相同的强调色。请让我知道我在这里可能做错了什么。

4

1 回答 1

2

this is a question that comes up quite often.

Im afraid the answer is no, you can't change fonts or colors. One big part of Adaptive Cards is that the host (in this case MS Teams) decides the look and feel of cards. You can set colors in a limited way if you choose the danger, accent, warning etc colors but you can't change the colorcode directly. The actual color for lets say danger is picked by the host you're sending the card to.

You can set a background as you've done in your example but that still isn't a real "background color" its just an image used as card background.

The "setHostConfig" part you are talking about can only be used if you are rendering the card yourself. If you want to know which things are customizable if you're the host yourself, have a look here: https://docs.microsoft.com/en-us/adaptive-cards/rendering-cards/host-config

Tim

于 2020-07-10T08:12:36.563 回答