[TIMOB-1968] Android - View ignores width w/ left & right set.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2011-04-15T03:06:52.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.5.0 |
Components | Android |
Labels | android, defect, ignore, left, right, view, width |
Reporter | Mike Robinson |
Assignee | Don Thorp |
Created | 2011-04-15T03:06:51.000+0000 |
Updated | 2017-03-02T18:18:02.000+0000 |
Description
Under the iOS implementation if you create a view with a width of 30 and then set left & right you get a view of 30 centered within the window. In Android, this is presently creating a view that stretches to fill the entire left/right space completely ignoring the width.
var win = Titanium.UI.currentWindow;
win.add(Titanium.UI.createView({
backgroundColor: 'red',
top: 10,
left: 5,
right: 5,
width: 75,
height: 75
}));
If you want it centered, you should leave off left and right. The condition is technically undefined. We will be formalizing what should happen in undefined conditions, but averaging out the space is not what one would normally expect.
I agree that this condition isn't exactly defined, however since it is performing that way on iOS I kind of expected it to transfer over (you see it in one implementation, you would normally expect it in the other).
The challenge for me lies in the fact, I am trying to place multiple objects in a horizontal line, keeping them centered in both orientations of the window. See my example below in iOS to see what I am trying. While in this example I could create a view, add one item left, one item right, and another undefined....the challenge comes that I am trying to add 7 items horizontally. What do you recommend then?
var win = Titanium.UI.currentWindow;
win.add(Titanium.UI.createView({
win.add(Titanium.UI.createView({
win.add(Titanium.UI.createView({
In the future, please go through helpdesk or Q&A LH is for verified problem only and not general support.
Simply create a View with only width and height defined, then add your other views to it defining height, width, and left. The container view will center and the other views will be relative to the container views origin.
Closing as invalid.