Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24793] Android: Fix Ti.UI.View.center calculation #9125

Merged
merged 3 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,10 @@ public static void computePosition(View parent, TiDimension leftOrTop,
int leftOrTopPixels = leftOrTop.getAsPixels(parent);
pos[0] = layoutPosition0 + leftOrTopPixels;
pos[1] = layoutPosition0 + leftOrTopPixels + measuredSize;
} else if (optionCenter != null && optionCenter.getValue() != 0.0) {
// Don't calculate position based on center dimension if it's 0.0
} else if (optionCenter != null) {
int halfSize = measuredSize / 2;
pos[0] = layoutPosition0 + optionCenter.getAsPixels(parent) - halfSize;
int centerPixels = optionCenter.getAsPixels(parent);
pos[0] = layoutPosition0 + centerPixels - halfSize;
pos[1] = pos[0] + measuredSize;
} else if (rightOrBottom != null) {
// peg right/bottom
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ description: |

For more details see:

* [UI Composite Layout Spec](http://docs.appcelerator.com/platform/latest/!/guide/UI_Composite_Layout_Behavior_Spec)
* [UI Composite Layout Spec](http://docs.appcelerator.com/platform/latest/#!/guide/UI_Composite_Layout_Behavior_Spec)

#### Size and Position

Expand Down