[TIMOB-28348] Android: Add TEXT_ALIGNMENT_JUSTIFY support
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-02-16T14:13:08.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.0.0 |
Components | Android |
Labels | alignment, android, label, parity |
Reporter | Michael Gangolf |
Assignee | Joshua Quick |
Created | 2021-02-10T20:32:33.000+0000 |
Updated | 2021-02-16T14:13:18.000+0000 |
Description
Currently there is no TEXT_ALIGNMENT_JUSTIFY for Android. This PR will add parity with iOS and allows the text to be justified.
It also adds the possibility to add features like TEXT_ALIGNMENT_JUSTIFY + last line right but I didn't include that in this PR to keep it simple and just add the iOS parity.
var win = Ti.UI.createWindow({
backgroundColor: 'white',
layout: "vertical"
});
var l = Ti.UI.createLabel({
color: "#000",
left: 20,
right: 20,
borderWidth: 1,
borderColor: "#000",
textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
text: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate"
});
var l1 = Ti.UI.createLabel({
color: "#000",
left: 20,
right: 20,
borderWidth: 1,
borderColor: "#000",
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
text: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate"
});
var l2 = Ti.UI.createLabel({
color: "#000",
left: 20,
right: 20,
borderWidth: 1,
borderColor: "#000",
textAlign: Ti.UI.TEXT_ALIGNMENT_JUSTIFY,
text: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate"
});
var l3 = Ti.UI.createLabel({
color: "#000",
left: 20,
right: 20,
borderWidth: 1,
borderColor: "#000",
textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
text: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate"
});
var btn = Ti.UI.createButton({
title: "all left"
})
var toggle = false;
btn.addEventListener("click", function() {
if (toggle) {
l.textAlign = Ti.UI.TEXT_ALIGNMENT_LEFT;
l1.textAlign = Ti.UI.TEXT_ALIGNMENT_CENTER;
l2.textAlign = Ti.UI.TEXT_ALIGNMENT_JUSTIFY;
l3.textAlign = Ti.UI.TEXT_ALIGNMENT_RIGHT;
} else {
l.textAlign = Ti.UI.TEXT_ALIGNMENT_LEFT;
l1.textAlign = Ti.UI.TEXT_ALIGNMENT_LEFT;
l2.textAlign = Ti.UI.TEXT_ALIGNMENT_LEFT;
l3.textAlign = Ti.UI.TEXT_ALIGNMENT_LEFT;
}
toggle = !toggle;
})
win.add([l, l1, l2, l3, btn]);
win.open();
win.addEventListener("open", function() {
console.log(l.textAlign);
console.log(l1.textAlign);
console.log(l2.textAlign);
console.log(l3.textAlign);
})
PR: https://github.com/appcelerator/titanium_mobile/pull/12464
FR Passed, waiting on Jenkins build.
merged to master for 10.0.0 target