[TIMOB-10004] Android: LeftImage inconsistent left position
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Low |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | Release 2.1.0 |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | api, parity |
| Reporter | Neville Dastur |
| Assignee | Unknown |
| Created | 2012-06-24T05:53:43.000+0000 |
| Updated | 2018-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();
})();
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
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
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.
Regards, Anirudhif(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, });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