imageview总是以tableview为中心

时间:2016-09-13 15:38:05

标签: ios imageview tableview appcelerator

我在IOS和Android中有一个appcelerator项目。

问题是我需要在行内部使用imageview的tableview。 在Android中,我可以将image1放在左边框附近,但在iOS中,imageview始终居中。 问题出在哪里????

由于

我的代码:

for (i=0;i<NRegistros;i++){

    TablaSerieTermostatos[i]=rows.field(0);
    leoSerie=rows.field(0);
    TablaPinTermostatos[i]=rows.field(1);
    leoPin=rows.field(1);
    TablaNombreTermostatos[i]= rows.field(2);
    TablaTemperTermostatos[i]= rows.field(345);

    var nuevaRow=Ti.UI.createTableViewRow({height:200, backgroundSelectedColor: "white"});  

    var cuadroexterno=Ti.UI.createView({
        id: "CuadroExterno",
        backgroundColor: "white" ,
        height: "100%",
        width: "100%",
        left:"0%",
        top:"5%"
    });
    var titulo1=Ti.UI.createLabel({
        id: "NombreTerm",
        text: TablaNombreTermostatos[i],
        font: {fontSize: '27'},
        color: "#0060a7" ,
        textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT, 
        left: "50%",
        top:"35%"
    });
    var imagen1=Ti.UI.createImageView({
        id: "Radiador",         
        image: "/Copiar Emisor.png",
        height: "70%",
        //left:"15%",
        top:"10%"
    });                 


    if (Ti.Platform.name=="iPhone OS") {
        imagen1.right = "40%";
        titulo1.left = "55%";
    }       
    else imagen1.left="15%";

    cuadroexterno.add(imagen1);
    cuadroexterno.add(titulo1);
    nuevaRow.add(cuadroexterno);        

    $.TablaCopiar.appendRow(nuevaRow);
    rows.next();
}       

合金:

    <TableView id="TablaCopiar" top="20%" height="80%" left="0%" zindex="20" width="100%" backgroundColor="white" visible="false" separatorColor="gray" >
    </TableView>

The screen in IOS

The screen in Android

1 个答案:

答案 0 :(得分:1)

在创建名为 TableRow

的新控制器后尝试此代码
var table_rows = [];

for (i=0;i<NRegistros;i++){
    TablaSerieTermostatos[i]=rows.field(0);
    leoSerie=rows.field(0);
    TablaPinTermostatos[i]=rows.field(1);
    leoPin=rows.field(1);
    TablaNombreTermostatos[i]= rows.field(2);
    TablaTemperTermostatos[i]= rows.field(345);

    table_rows.push(Alloy.createController('TableRow', {
        text : TablaNombreTermostatos[i]
    }).getView());  

    rows.next();
}       

$.TablaCopiar.data = table_rows;

<强> TableRow.xml

<Alloy>
    <TableViewRow height="200" backgroundSelectedColor="white">
        <View class="views">
            <Label id="NombreTerm" class="row-labels" />
            <ImageView id="Radiador" class="left-images"/>
        </View>
    </TableViewRow>
</Alloy>

<强> TableRow.tss

".views" : {
    width : Titanium.UI.FILL,
    height : Titanium.UI.FILL,
    backgroundColor : "white"
}

".left-images" : {
    left : 70,
    height : '70%',
    image : "/Copiar Emisor.png"
}

".row-labels" : {
    textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT,
    color : "#0060a7",
    font: {fontSize: '27'}
}

<强> TableRow.js

$.NombreTerm.text = $.args.text;