Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10004] Android: LeftImage inconsistent left position

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 2.1.0
Fix Version/sn/a
ComponentsiOS
Labelsapi, parity
ReporterNeville Dastur
AssigneeUnknown
Created2012-06-24T05:53:43.000+0000
Updated2018-02-28T20:04:14.000+0000

Description

The left offset for views added after leftImage to a tableviewrow differs between iOS and Android On iOS it seems to be 0, whereas on android it is the size of the image. So for consistent behaviour a work around that alters the left property of views is required
// This is a single context application with mutliple windows in a stack
(function() {	
	var self = Titanium.UI.createWindow({
        title: 'Window',
        backgroundColor: 'white',
        });    

    var tableview = Ti.UI.createTableView({});

    var lbl = Ti.UI.createLabel({
            text: 'Label to the right of the left image',
            font: {
                fontSize : '16dp'
            },
            textAlign: 'left',
            left: 0,
        });

    var row = Ti.UI.createTableViewRow({
            className: 'datarow',
            height: '77dp',
            leftImage: '/KS_nav_views.png'
        });
    row.add(lbl);
    tableview.appendRow(row);
    
    self.add(tableview);
    self.open();
})();
Using the title property in the row puts the text as expected, i.e. to the right of the image
(function() {	
	var self = Titanium.UI.createWindow({
        title: 'Window',
        backgroundColor: 'white',
        });    

    var tableview = Ti.UI.createTableView({});

    var row = Ti.UI.createTableViewRow({
            title: 'Test'
            className: 'datarow',
            height: '77dp',
            leftImage: '/KS_nav_views.png'
        });

    tableview.appendRow(row);
    
    self.add(tableview);
    self.open();
})();

Comments

  1. Anirudh Nagesh 2012-07-03

    Is it leftImage or backGroundImage? The issue is not clear. Sample code does not reproduce the issue. WOrks fine with left:0 on both Android and iOS. https://gist.github.com/9eb2ba10f35a7ab155a3
  2. Neville Dastur 2012-07-03

    The original code that I posted was incorrect as you rightly pointed. Since then I have created a little bug project and so it's much easier to make minimal cases. The code that show the error is now in the description
  3. Anirudh Nagesh 2012-07-03

    Hi, Yes, I see the behavior now. I believe its a parity issue. I will discuss this with the engineering team. Meanwhile, you can use the workaround below.
        if(Ti.Platform.name == 'android') leftMargin = '0dp'; else leftMargin = '58dp';
        var label = Ti.UI.createLabel({
                   text: 'Label to the right of the left image',
                   font: {
                       fontSize : '16dp'
                   },
                   textAlign: 'left',
                   left:leftMargin,
                   //right:10,
               });
       
    Regards, Anirudh
  4. Neville Dastur 2012-07-03

    No problem. Not that I think the workaround will depend on the left image size. And BTW it is still present on SDK 2.1.0 Thanks

JSON Source