Problem Description
ScrollTo function takes two coordinate parameters. When the default unit configured for the project is dp, the function still takes the parameters as system units instead causing a behavior disparity between iOS and Android.
Steps to reproduce
1. Create a new mobile project (classic titanium)
2. Paste this code into app.js:
var win = Titanium.UI.createWindow({
backgroundColor:'#fff',
layout:'vertical'
});
var btn = Ti.UI.createButton({
title : 'Scroll',
height : 'auto',
width : 'auto',
top : 20,
color:'#000'
});
btn.addEventListener('click', function() {
scrollView.scrollTo(0,500);
});
var scrollView = Ti.UI.createScrollView({
contentWidth : 'auto',
contentHeight : 'auto',
layout : "vertical",
showVerticalScrollIndicator : false,
showHorizontalScrollIndicator : true,
height : '100%',
width : '100%',
scrollType : 'vertical',
horizontalWrap : false,
backgroundColor:'white',
top:10
});
var view1 = Ti.UI.createView({
height : '200',
backgroundColor:'red'
});
var view2 = Ti.UI.createView({
height : '200',
backgroundColor:'green'
});
var view3 = Ti.UI.createView({
height : '200',
backgroundColor:'blue'
});
var view4 = Ti.UI.createView({
height : '200',
backgroundColor:'yellow'
});
win.add(btn);
win.add(scrollView);
scrollView.add(view1);
scrollView.add(view2);
scrollView.add(view3);
scrollView.add(view4);
win.open();
Extra info
This code scrolls to the middle of the third view on iOS. On Android the scroll location depends on the density of the device used.
I'm having the same issue on Ti SDK 5.1.2.GA
What units need scrollT(x,y) ??? dp or px?? on Android
Looking at the [source](https://github.com/appcelerator/titanium_mobile/blob/415bd6c66dcc55b1a59a59574f3babd3c3a84ede/android/modules/ui/src/java/ti/modules/titanium/ui/ScrollViewProxy.java#L121) I'd say px on Android. We should document (and improve that to accept default unit) that.
Yes, I'm having a lot of problems with that. this is crazy!
Hi, I have tested this issue with latest environment. Still this is a valid issue for android. Test Environment :
Thanks
master: https://github.com/appcelerator/titanium_mobile/pull/8743. The parity is still a bit off. I suggest a better way to scroll would be to scroll to actual UI components instead if you want precision and better consistency for behavior.
Verified fixed in 6.1.0.v20170313171259. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/8743