【问题标题】:Titanium.UI.Button property image is not working as given in documentTitanium.UI.Button 属性图像未按文档中给出的那样工作
【发布时间】:2012-04-15 20:05:28
【问题描述】:

我想在带有文本的按钮上显示图标。我为此使用以下代码。

 var refreshButton = Titanium.UI.createButton({
        image :'refresh.jpg',
        top : 0,
        height : 100,
        left : width,
        width : width,
        title : 'Refresh'
    })

来自 appcelerator api 文档。

image:显示在按钮左侧的图像 标题

但像 backgroundImage 一样工作

我错过了什么吗?

【问题讨论】:

  • 我也面临同样的问题。我在 Titanium.UI.Button 上找到了两个不同的文档,其中 image 的摘要不同。 Link 1Link 2

标签: android image button titanium appcelerator


【解决方案1】:

我遇到了同样的问题。

但当图像小于按钮时,它不会发生。

我使用了大小为按钮 1/4 的图像,它解决了我的问题。

【讨论】:

    【解决方案2】:

    尝试将图像添加为按钮中的图像视图:

        var button = Ti.UI.createButton({backgroundColor:'black',title:'General Info',textAlign:'left',width:210, height:30,top:20,left:20, color:'white', font:{fontFamily:'AppleGothic',fontWeight:'bold',fontSize:20}}); 
    
        var icon = Ti.UI.createImageView({
            image : "../images/icon.png",
            height : 20,
            width  :20,
            left : 5
        });
    
    button.add(icon)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多