[TIMOB-17491] Android: contentOffset property of UI.ScrollView not accessible
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2014-11-04T22:42:44.000+0000 |
| Affected Version/s | Release 3.4.0 |
| Fix Version/s | Release 3.4.2, Release 3.5.0, Release 4.0.0 |
| Components | Android |
| Labels | android, contentOffset, parity, scrollview |
| Reporter | Kevin Frugier |
| Assignee | Hieu Pham |
| Created | 2014-08-11T13:59:17.000+0000 |
| Updated | 2015-04-19T16:07:09.000+0000 |
Description
The contentOffset property (reflecting what's currently visible in a ScrollView), is undefined on Android.
Documentation of [UI.ScrollView|(http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.ScrollView-property-contentOffset] says it's available on Android since 0.9, however in version 3.3.0 GA it (still?) doesn't work.
Notes
* contentOffset is not set manually anywhere in the test code * I'm talking about UI.ScrollView, not tableview or listviewHow to reproduce
Create a ScrollView
<Alloy>
<ScrollView id="myscrollview" />
</Alloy>
In the controller, try to get the value of the property :
alert($.myscrollview.contentOffset.x);
Can reproduce with SDK 3.2.3 GA and 3.3.0 GA on Android 4.2.2. Here is a simple test case.
var win = Ti.UI.createWindow({ backgroundColor: 'white', exitOnClose: true, fullscreen: false, title: 'ScrollView Demo' }); var scrollView = Ti.UI.createScrollView({ contentWidth: 'auto', contentHeight: 'auto', showVerticalScrollIndicator: true, showHorizontalScrollIndicator: true, height: '80%', width: '80%' }); var view = Ti.UI.createView({ backgroundColor:'#336699', borderRadius: 10, //top: 10, height: 2000, width: 1000 }); // output the contentOffset value Ti.API.info(scrollView.contentOffset.x); scrollView.add(view); win.add(scrollView); win.open();master PR: https://github.com/appcelerator/titanium_mobile/pull/6292 3.4.X PR: https://github.com/appcelerator/titanium_mobile/pull/6313
The contentOffset property for ScrollView is accessible now and does not show any error. Tested with both the alloy and classic code provided. Verified on: SDK: 3.5.0.v20141124155715 Studio: 3.4.1.201410281743 CLI: 3.4.1 Alloy: 1.5.1 Device: Samsung Galaxy S5 (v4.4.2)
It doesn't work with SDK3.5.1.GA