-1

我有很多不同宽度和高度的图片。

我想设置一个列表,包含 100% 宽度和动态高度的图像,但我在 Smartface 上找不到任何设置,如“adjustViewBounds”。

我的图像有不同的宽度,所以自动调整“图像大小属性”不适合我。

4

2 回答 2

0

您想将此列表用于重复框行还是用于什么?动态地,您可以设置任何页面中的图像高度和图像宽度。

于 2015-01-28T09:03:11.803 回答
0

如果您使用repeatbox 并希望更改与图像大小相关的rowHeights,您可以使用repeatBox 的customRowHeight 方法。

像 ;

var rBox = new SMF.UI.Repeatbox();
 // adding items to repeatbox
 /* If this property is assigned to a function, this function will be called. This function results will override any height value previously given
 * @param {number} maxRows  Required. Maximum value index of rows to be added to repeatbox
 * @param {number} minRows  Optional. Minimum value index of rows to be added to repeatbox
 * @return {object} A custom object with two key properties (activeItem , inactiveitem) which values are number arrays
  */
 rbox.customRowHeight = function (maxRows, minRows) {
    var i;
    var result = {
        activeItem : [],
        item: []
    };
    for (i = minRows or  0; //Default value if minRows is not provided
        i < maxRows; i++) {
        switch (i) {
        case 0:
            result.activeItem[i] = result.item[i] = "50dp";
            break;
        case (i <= 10 and i > 0):
            result.activeItem[i] = "40dp";
            result.itemtem[i] = "35dp";
            break;
        default:
            result.activeItem[i] = result.item[i] = 30;
        }
    }
    return result;
 };

除此之外,您还可以创建一个 ScrollView 并使用您的图像动态填充它。您可以将其布局设置为线性,而不是将 ScrollView 的 autoSize 功能设置为 true。通过这种方式,您可以获得 ScrollView 的动态高度,并且可以将它们逐行添加到 scrollView 中。

有关布局的更多信息:http ://www.smartface.io/developer/guides/controls/layouts/

于 2015-03-02T11:13:54.147 回答