[TIMOB-11640] Android: Remote Images inside a vertical ScrollView not scaling properly (only seen after closing and reopening the app couple of times)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-02-25T18:33:26.000+0000 |
Affected Version/s | Release 2.1.3 |
Fix Version/s | Release 3.1.0, 2013 Sprint 04 Core, 2013 Sprint 04 |
Components | Android |
Labels | core, layout, module_scrollView, qe-testadded, triage |
Reporter | Amuktha Akkinepally |
Assignee | Allen Yeung |
Created | 2012-11-01T21:22:22.000+0000 |
Updated | 2013-10-03T13:12:48.000+0000 |
Description
When trying to add an imageView to a scrollView with a vertical layout, the imageView has a height that is much larger than the image that is displayed. The image is being scaled and displayed but there is a white blank space displayed above,thought the top is set as '10dp'. It works fine when the app is loaded for the first time.
Steps to reproduce:
1.Load the below app.js 2.Run it on Android Device (4.1) 3.Close and re-open the app by just tapping on the home. 4.After doing it for 4 - 5 times on an average you can see that the height is set to 10dp anymore. Expected: There should be no space above the image, no matter how many times we launch the app. Actual Behavior: There is some empty space above and below the image after folding and re-opening the app couple of times.app.js:
var detailWindow = Titanium.UI.createWindow({
backgroundColor : '#fff'
});
var detailScrollView = Ti.UI.createScrollView({
layout : 'vertical'
});
var imageView = Ti.UI.createImageView({
image : "https://s3.amazonaws.com/static.tumblr.com/6t3upxl/Aawm08w0l/khout-kitten-458882.jpeg",
top : '10dp'
});
detailScrollView.add(imageView);
detailWindow.add(detailScrollView);
detailWindow.open();
I spent some time on this but couldn't come up with a solution. Here is my observation Since size is not specifiex, the image is first loaded with the original size and when the container(scrollview) do the layout it restrict the size to the scrollview width but the height is set to the originial image height. When the image is drawn, since the width is less, the hieght is also reduced to keep the aspect ratio same and the remaining spaces are see on top and bottom.
https://github.com/appcelerator/titanium_mobile/pull/3897
Tested with: Titanium Studio, build: 3.0.3.201302201202 Titanium SDK, build: 3.1.0.v20130311012453 Devices: Nexus4 4.2(There is space above the image at launch only, the image is scaling properly after closing and reopening the app ) Samsung GalaxyS3 4.0.4 (There is space above the image, no matter how many times we launch the app.)
Tested with: SDK: 3.1.0.v20130312015656 Studio: 3.1.0.201303091040 Device: Nexus7(v android 4.1) Working as expected