Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28348] Android: Add TEXT_ALIGNMENT_JUSTIFY support

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2021-02-16T14:13:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 10.0.0
ComponentsAndroid
Labelsalignment, android, label, parity
ReporterMichael Gangolf
AssigneeJoshua Quick
Created2021-02-10T20:32:33.000+0000
Updated2021-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);
})

Comments

  1. Michael Gangolf 2021-02-10

    PR: https://github.com/appcelerator/titanium_mobile/pull/12464
  2. Samir Mohammed 2021-02-12

    FR Passed, waiting on Jenkins build.
  3. Christopher Williams 2021-02-16

    merged to master for 10.0.0 target

JSON Source