Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6992] iOS: UI - ActivityIndicator incorrect positioning with left and right properties

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-04-02T13:40:12.000+0000
Affected Version/sRelease 1.7.5
Fix Version/sSprint 2012-05, Release 2.0.0
ComponentsiOS
Labelsmodule_activityindicator, parity, qe-testadded
ReporterShawn Lipscomb
AssigneeVishal Duggal
Created2011-12-22T10:03:40.000+0000
Updated2012-04-02T13:40:12.000+0000

Description

Actual Result

Setting the "left" or "right" property of a Ti.UI.ActivityIndicator yields incorrect positioning. The ActivityIndicator seems to be centering on a horizontal coordinate that is relative to the center of the view that the ActivityIndicator is added to. Examples: * ActivityIndicator with left=0 or right=0 will be centered within its view. * ActivityIndicator with left=50 will have its center positioned 50px to the right of the center of its view. * ActivityIndicator with right=-50 will have its center positioned 50px to the right of the center of its view. * ActivityIndicator with right=50 will have its center positioned 50px to the left of the center of its view.

Expected result

When the "left" or "right" property is supplied, the Ti.UI.ActivityIndicator should be positioned within the view it is added to accordingly, just like any other component would be (button, image, label, etc).

Test case

var win1 = Ti.UI.createWindow({
  backgroundColor:'#fff'
});

var label1 = Ti.UI.createLabel({
  backgroundColor:'green',
  color:'white',
  text:'Spinner should be on top of the X',
  font:{fontSize:20,fontFamily:'Helvetica Neue'},
  textAlign:'center',
  top:40,
  height:40,
  width:'auto'
});
win1.add(label1);

var view1 = Ti.UI.createView({
  backgroundColor:'yellow',
  height:30,
  top:100,
  width:100
});
win1.add(view1);

var spin1=Ti.UI.createActivityIndicator({
  //right:25,
  left:25,
  style:Ti.UI.iPhone.ActivityIndicatorStyle.DARK
});
view1.add(spin1);

var marker1=Ti.UI.createLabel({
  //right:25,
  left:25,
  height:'auto',
  width:'auto',
  text:'X'
});
view1.add(marker1);

win1.open();
spin1.show();
The code above should place the spinner right on top of the X.

Workaround

Explicitly set the activityIndicator width and height properties to 'auto'

Comments

  1. Paul Dowsett 2011-12-22

    Thanks for this ticket, Shawn. Would you mind completing the environment field, so that I may move it to the main project? Cheers
  2. Paul Dowsett 2011-12-22

    I will close this for now. Please reopen the ticket once it is complete, and I will move it to the main project.
  3. Shawn Lipscomb 2011-12-22

    Paul, I added "iOS 5.0, OSX 10.7.2" and my Ti Studio version to the environment section. Is that what you needed? I cannot reopen the ticket myself (or I don't know how to). Please reopen and move to main project. Thanks.
  4. Paul Dowsett 2012-01-03

    Thanks for the email, Shawn. I will look at this in detail tomorrow.
  5. Paul Dowsett 2012-01-05

    Just to note, I've accepted this ticket.
  6. Blain Hamon 2012-03-05

    Tentatively linking to TIMOB-7643. The behavior on activity indicator was because it was doing fill, not size, sizing by default. The new composite layout behavior may fix this.
  7. Blain Hamon 2012-03-06

    Vishal verified that TIMOB-7643 will fix this.
  8. Blain Hamon 2012-03-06

    Mega-pull #1523 fixes this.
  9. Wilson Luu 2012-03-15

    Closing bug. Verified fix on: SDK build: 2.0.0.v20120315091738 Titanium Studio, build: 2.0.0.201203142055 xcode: 4.2 Device: iphone 4s (5.0.1)
  10. Michael Pettiford 2012-04-02

    Reopening/closing to add/remove labels

JSON Source