{ "id": "64044", "key": "TIMOB-3412", "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": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-06-08T23:29:21.000+0000", "created": "2011-04-15T03:44:00.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "defect", "reported-1.6.0" ], "versions": [], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-06-08T23:29:21.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}
Given a native android project (non-titanium) with the\nfollowing:
\n\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"fill_parent\" \n android:layout_height=\"fill_parent\" \n android:orientation=\"vertical\" >\n<ImageView \n android:src=\"@drawable/test\" \n android:id=\"@+id/iv\" \n android:layout_width=\"wrap_content\" \n android:layout_height=\"wrap_content\"\n/>\n</LinearLayout>
\n
\nA file, test.png, in res/drawable-mdpi
. The file is\na 50 pixel by 50 pixel graphic.
The application running on a high-density device.
\nWhen rendered, the image view will be 75 x 75 pixels (50 * 1.5),\nbecause the graphic file was in the mdpi (medium\ndensity) drawable folder and the device is a high density device,\nso Android automatically scales it up.
\nGiven a Titanium project with the\nfollowing:
\nThe same test.png from above (50x50) in the project's\nplatform/android/res/drawable-mdpi
folder.
The following app.js:
\n\nTitanium.UI.setBackgroundColor('#000');\nvar win = Titanium.UI.createWindow({ \n title:'Test',\n backgroundColor:'#000',\n exitOnClose: true\n});\n\nvar iv = Ti.UI.createImageView({\n left: 0, top: 0, height: 'auto', width: 'auto',\n image: Ti.App.Android.R.drawable.test\n});\nwin.add(iv);\n\nvar btn = Ti.UI.createButton({\n top: '50%', height: 'auto', width: 'auto', left: 0,\n title: 'Get dimensions'\n});\nbtn.addEventListener('click', function(){\n var size = iv.size;\n Ti.API.info(\"ImageView dimensions: \" + size.width + \"x\" + size.height);\n});\nwin.add(btn);\nwin.open();
\n
\nWhen run, and when clicking the \"Get dimensions\" button, the\nlogcat output will show that the rendered width and height remain\nat 50x50, so the image was not scaled up\nautomatically. I believe it should have been.
\nExpected outcome: The logcat output from the\nabove Titanium project should show \"ImageView dimensions:\n75x75\".
The reason: TiDrawableReference (responsible for fetching and\nscaling images), when it gets images that are resource drawables,\nuses Resources.openRawResource() and checks the bounds of that raw\ndrawable -- which are 50x50. It doesn't know where the resource\ncomes from (i.e., from which drawable-?dpi resource folder it comes\nfrom), so even if it tried to scale it (which it doesn't even try),\nit wouldn't know whether it should scale it and by how much to\nscale it.