[TIMOB-5125] Android: Scrollview, with a WebView added, scrolls to the position of the WebView when the ScrollView opens
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2013-05-23T18:42:33.000+0000 |
Affected Version/s | Release 1.7.5 |
Fix Version/s | n/a |
Components | Android |
Labels | core, exalture, look1, tbs-1.8.2 |
Reporter | Sandeep Bhimavarapu |
Assignee | Sunila |
Created | 2011-08-26T14:19:25.000+0000 |
Updated | 2017-03-21T21:06:35.000+0000 |
Description
ScrollView, which has a WebView, scrolls to the position of WebView, when it is opened.
If there is more than one WebView added, then it shows (scrolls to) the position of the last added WebView.
The sample code is below.
This code had a ScrollView with a View and WebView added to it. When, the app is opened, by default the WebView is seen which is way below the View.
*Sample Code*
{noformat}
var win = Titanium.UI.createWindow({backgroundColor:'#fff'});
var scrollView = Titanium.UI.createScrollView({ contentWidth: 'auto', contentHeight: 'auto', showVerticalScrollIndicator: true, });
win.add(scrollView);
var v = Ti.UI.createView({backgroundColor : 'red', height : 500, top : 100});
scrollView.add(v);
var wv = Titanium.UI.createWebView({ url:'http://www.google.com', height: 300, top:1000, scalesPageToFit: true });
scrollView.add(wv);
win.open();
// Workaround
// wv.addEventListener('beforeload',function(){
// scrollView.scrollTo(0,0);
// scrollView.show();
// });
// win.addEventListener('open',function(){
// scrollView.hide();
// });
{noformat}
*Expected Behavior*
- ScrollView should be at position (0,0) when it opens. In this case, the view with "red" background color should be seen in full.
*Observed Behavior*
- ScrollView shows the position of WebView. In this case, the WebView with "http://www.google.com" is seen in full and not the "red" colored view.
*Steps to Reproduce*
- Please use the sample code provided in app.js and the result is seen right away.
*Other Observations*
- If the ScrollView has more than one WebViews added, the WebView that was added last to the ScrollView will be shown.
- For example, if the another WebView is added as below to the sample app, this WebView (with "http://www.appcelerator.com") is seen when the ScrollView opens
- {noformat}
var wv1 = Ti.UI.createWebView({ url : 'http://www.appcelerator.com', height : 300, top : 700, scalesPageToFit : true });
scrollView.add(wv1);
{noformat}
Thomas discussed the reason for closing.
This is an Android platform behavior to scroll to any focusable control which is in the visible area.The control doesn't need to be a webview, even a textview can be used to reproduce the behavior.
Closing ticket as invalid.