响应式Chrome扩展程序图标

时间:2020-06-02 13:33:37

标签: javascript google-chrome google-chrome-extension responsive-design responsive

因此,谷歌浏览器扩展程序现在要求图标尺寸为16x16、19x19、38x38、48x48和128x128像素。

我已将图标包含在压缩文件中,但是如何调整代码以使图标响应并显示正确的大小。

当前,我有以下代码指向图标图像:

n = int(input().strip())

if n%2==0 and (n in range(2,6) or n > 20):
    print("Not Weird")
else:
    print("Weird")

显然,此代码在只有一个图像大小的基础上起作用,因此我认为需要重构代码以使其具有响应能力?但是我找不到关于此的任何谷歌指南。

任何建议,不胜感激。

谢谢

1 个答案:

答案 0 :(得分:0)

您是否尝试过定义对象内部的大小?

if(toggle.checked)
{
    chrome.browserAction.setIcon({
       path : {
         //Obviously you can change the pixel size to whatever you want
         "38": "green_icon.png"
       }
    });
} else {
    chrome.browserAction.setIcon({
       path : {
         //Obviously you can change the pixel size to whatever you want
         "38": "red_icon.png"
       }
    });
}