{ "id": "138267", "key": "TIMOB-17886", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2014-10-19T13:28:21.000+0000", "priority": null, "labels": [ "TCSupportTriage", "android", "imageView", "width" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:04:20.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "On Android. Not tried on iOS.\r\n\r\nIf set ImageView width = Ti.UI.FILL:\r\n\r\nand image width (in pixels) > screen width (in pixels), then ImageView works fine, and image SHRINKS to fit screen width, while keeping aspect ratio.\r\n\r\nHowever if image width (in pixels) < screen width (in pixels), ImageView will keep aspect ratio, but will not STRETCH image to full width of screen.\r\n\r\nTry code below using an image (354 × 518 pixels) off Wikipedia. You will see the white border will be at screen edges, but actual images will not stretch that far. Image stretches some, but not all the way to FILL.\r\n\r\nCAVEAT - make sure you are using a phone with a high density screen - for example a Nexus 5. Lower density phones this issue is not as apparent.\r\n\r\nvar imageView = Ti.UI.createImageView({\r\n\t\t\t image: \"http://upload.wikimedia.org/wikipedia/commons/1/14/Animal_diversity.png\",\r\n\t\t\t\twidth: Ti.UI.FILL,\r\n\t\t\t\t// height: Ti.UI.FILL,\r\n\t\t\t\t// height: \"300dp\",\r\n\t\t\t\tborderWidth: \"3dp\",\r\n\t\t\t\tborderColor: \"white\",\r\n\t\t\t\tborderRadius: \"4\",\r\n\t\t\t});\r\n\r\n$.win.add(imageView);\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "Android:ImageView does not STRETCH images to fill screen", "creator": { "name": "matt_m", "key": "matt_m", "displayName": "Matt Moskal", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "matt_m", "key": "matt_m", "displayName": "Matt Moskal", "active": true, "timeZone": "America/New_York" }, "environment": "Android\r\nTitanium SDK 3.4.0.GA", "comment": { "comments": [ { "id": "328751", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Based on your code, you have commented height property.\r\nYou should user like: \r\n{code}\r\nvar win = Ti.UI.createWindow({ \r\n backgroundColor: '#fff',\r\n});\r\n \r\nvar imageView = Ti.UI.createImageView({ \r\n\timage: \"http://upload.wikimedia.org/wikipedia/commons/1/14/Animal_diversity.png\", \r\n\twidth: Ti.UI.FILL, \r\n\theight: Ti.UI.FILL \r\n});\r\n\r\nwin.add(imageView);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-10-21T04:13:51.000+0000", "updated": "2014-10-21T04:13:51.000+0000" }, { "id": "328849", "author": { "name": "matt_m", "key": "matt_m", "displayName": "Matt Moskal", "active": true, "timeZone": "America/New_York" }, "body": "Hi Shou Liang. Thank you for your reply. Several quick points.\r\n\r\n1. To maintain aspect ratio of an image, as you describe, is not how ImageView is supposed to work. If you set BOTH the height & width, ImageView does not maintain aspect ratio. If you fix the height or the width (but no both), aspect ratio is supposed to be maintained. This behavior is documented.\r\n\r\nhttp://docs.appcelerator.com/titanium/3.0/#!/guide/Images_and_ImageView_APIs-section-29004912_ImagesandImageViewAPIs-TheImageView\r\n\r\n=====\r\n\r\nIf you specify a width and/or height property on the image, the image will be scaled to fit according to these considerations:\r\n\r\nIf the ImageView's height and width are specified, the images will be scaled unproportionally to fit the dimensions. The graphic's aspect ratio will NOT be maintained.\r\nIf either the ImageView's height or width are specified (not both), the image will be scaled to fit the specified dimension. The graphic's aspect ratio will be maintained.\r\n=====\r\n\r\n2. If you set both the width & height to FILL, ImageView acts somewhat oddly. Aspect ratio is maintained, but the ImageView (but not the image itself) appears to become very tall. You can see this if you set top=\"0dp\". The image will not be at the top. In addition, this is not how ImageView is documented to work. The image should actually be stretched to fill the entire screen - losing aspect ratio.\r\n\r\n3. The above is for images the need to be STRETCHED. There seems no problem if images are SHRUNK.\r\n\r\n4. I have not tested for various aspect ratios - w>h, w=h, w