簡體   English   中英

調整 Viber bot 中按鈕的高度

[英]Adjust heigh for buttons in Viber bot

我需要使用rich_media消息類型和 Viber REST API 在 Viber 機器人中顯示按鈕。 呈現按鈕時,富媒體元素具有固定高度(參見屏幕截圖)。 如果 Rich Media 元素中有五個按鈕,則最后一個按鈕下方會出現一些空白位置。 在此處輸入圖像描述

我用於渲染按鈕的源代碼:


var reply = {
    type: "raw",
    method: "send_message",
    body: {
        receiver: $request.data.chatId,
        sender:{
            name: "John McClane",
            avatar: "http://avatar.example.com"
        },
        min_api_version: 2,
        type: "rich_media",
        rich_media: {
            Type: "rich_media",
            Buttons: [
                {
                    Rows: 1,
                    ActionBody: "Option 1",
                    ActionType: "reply",
                    Text: "Option 1"
                },
                {
                    Rows: 1,
                    ActionBody: "Option 2",
                    ActionType: "reply",
                    Text: "Option 2"
                },
                {
                    Rows: 1,
                    ActionBody: "Option 3",
                    ActionType: "reply",
                    Text: "Option 3"
                },
                ...
            ]
        }
    }
}

我需要調整 Rich Media 元素的高度,以便元素根據按鈕的數量進行拉伸。 有沒有辦法設置高度或禁用富媒體元素的默認高度?

自己找到了解決方案。 有一個名為 ButtonsGroupRows 的參數(rich_media.ButtonsGroupRows,有關此參數的文檔)。 7 是默認值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM