Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14732] Android: imageView inside a scrollView is not correctly resized

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-10-10T19:50:46.000+0000
Affected Version/sRelease 3.1.0, Release 3.1.1, Release 3.1.2
Fix Version/s2013 Sprint 21, 2013 Sprint 21 API, Release 3.2.0
ComponentsAndroid
Labelsmodule_scrollView, parity, qe-3.1.2, qe-testadded
ReporterFederico Casali
AssigneeSunila
Created2013-08-01T00:27:36.000+0000
Updated2014-04-21T10:10:09.000+0000

Description

Problem description

imageViews in a scrollView are not correctly resized on Android devices

Sample code

var win = Ti.UI.createWindow({
	title:'test',
	backgroundColor:'black'
});

var image = Ti.UI.createImageView({
	image:'apoc.jpg',
	top:5,
	width:'95%'
});

var scrollview = Ti.UI.createScrollView();

scrollview.add(image);
win.add(scrollview);

win.open();
(apoc.jpg attached to the project).

Steps to reproduce

Run the sample code using the attached image (image is bigger than the screen) Result: on Android device the 95% value for the width is respected, but the image is cropped instead of being correctly resized (as is correctly displayed on iOS). If the image is added to a normal view, is displayed correctly. Same behavior is reproducible on 3.1.1 GA and 3.1.0 GA, so is not a regression.

Attachments

FileDateSize
apoc.jpg2013-08-01T00:29:07.000+0000561621

Comments

  1. Sunila 2013-10-02

    Looks like the code was introduced as part of TIMOB-10358 but there was no mention of why this code was introduced. The tests in TIMOB-10358 also runs fine with this change. https://github.com/appcelerator/titanium_mobile/pull/4753
  2. Ping Wang 2013-10-02

    The scaling is disabled if the image view is in a scrollview. The scrollview can extend beyond the screen size, so the image view can extend beyond the screen size. Therefore if the image is larger than the screen size, we don't want to scale it to fit inside the screen. The above PR will introduce a regression. Run the test case attached below and see the regression introduced by this PR:
       var win = Ti.UI.createWindow({
           title:'test',
           backgroundColor:'black'
       });
        
       var image = Ti.UI.createImageView({
           image:'apoc.jpg',
           top:5
       });
        
       var scrollview = Ti.UI.createScrollView();
        
       scrollview.add(image);
       win.add(scrollview);
        
       win.open();
       
       
  3. Sunila 2013-10-05

    Updated the pull request with changes to address the scrollview issue
  4. Lokesh Choudhary 2013-10-22

    Verified the fix. The image is resized as expected. Thus closing. Environment: Appcel Studio : 3.2.0.201310221639 Ti SDK : 3.2.0.v20131022050844 Device: Samsung Galaxy S4 running android 4.2.2 CLI - 3.2.0 with hash 72f7426b4ee6c2d2883c666d5b7e03906a16012f

JSON Source