Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25838] iOS: Horizontal/Vertical layout miscalculates percent width/height when default unit is not "dp"

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 6.3.0, Release 8.0.0
Fix Version/sn/a
ComponentsiOS
Labelsdefaultunit, engSchedule, ios, layout, percent
ReporterJoshua Quick
AssigneeUnknown
Created2018-03-06T02:30:57.000+0000
Updated2019-04-16T16:16:10.000+0000

Description

*Summary:* When setting the "tiapp.xml" property "ti.ui.defaultunit" to a unit other than "dp", layouts "vertical" and "horizontal" will miscalculate percentage based "width" and "height" properties. *Steps to Reproduce:*

Modify project's "tiapp.xml" with the below "ti.ui.defaultunit" property. (Sets it to pixels.)

Build and run the below JavaScript on an iOS device.

Observe the size of the gray rectangle. It's supposed to be 50% wide and 50% tall.

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
	<property name="ti.ui.defaultunit" type="string">px</property>
</ti:app>
var window = Ti.UI.createWindow(
{
	layout: "vertical",
//	layout: "horizontal",
});
window.add(Ti.UI.createView(
{
	backgroundColor: "gray",
	borderColor: "black",
	borderWidth: "1dp",
	top: "25%",
	left: "25%",
	width: "50%",
	height: "50%",
}));
window.open();
*Result:* Looks like attached "Screenshot-Bad.png" where the gray rectangle is *NOT* centered onscreen, with a 50% width and 50% height. *Expected Result:* Should look like attached "Screenshot-Good.png". *Notes:* * This bug does not occur if "ti.ui.defaultunit" is set to "dp". * This bug does not occur with "composite" layouts, which works with all units. * This is not an issue with percentage based "top", "bottom", "left", or "right" properties. * This is not an issue on Android.

Attachments

FileDateSize
Screenshot-Bad.png2018-03-06T02:28:23.000+000020057
Screenshot-Good.png2018-03-06T02:28:27.000+000020007

Comments

No comments

JSON Source