{"id":30,"date":"2012-06-07T21:22:26","date_gmt":"2012-06-07T12:22:26","guid":{"rendered":"http:\/\/adreamer.godohosting.com\/en\/?p=30"},"modified":"2012-06-07T21:23:44","modified_gmt":"2012-06-07T12:23:44","slug":"android-titanium-recognizes-image-with-a-black-border-as-a-9-patch-image","status":"publish","type":"post","link":"http:\/\/milkdrops.net\/en\/archives\/30","title":{"rendered":"[Android] Titanium recognizes image with a black border as a 9-patch image"},"content":{"rendered":"<p>If you use a image with black border as a background image, this kind of error is occurred in Android.<br \/>\n(Related issue : <a href=\"https:\/\/jira.appcelerator.org\/browse\/TIMOB-4889\" target=\"_blank\">TIMOB-4889<\/a>)<\/p>\n<pre>\r\n06-07 16:56:04.507: E\/TiApplication(2738): (KrollRuntimeThread) [438,440] APP PROXY: ti.modules.titanium.app.AppModule@413ba7f8\r\n06-07 16:56:14.105: E\/TiApplication(2738): (main) [1156,8379] Sending event: exception on thread: main msg:java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0; Titanium 2.0.2,2012\/05\/30 10:21,2ff31a3\r\n06-07 16:56:14.105: E\/TiApplication(2738): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat java.util.ArrayList.get(ArrayList.java:304)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat org.appcelerator.titanium.util.TiNinePatchHelper.createChunk(TiNinePatchHelper.java:189)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat org.appcelerator.titanium.util.TiNinePatchHelper.process(TiNinePatchHelper.java:52)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:308)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat org.appcelerator.titanium.util.TiUIHelper.buildBackgroundDrawable(TiUIHelper.java:493)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat org.appcelerator.titanium.view.TiUIView.handleBackgroundImage(TiUIView.java:783)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat org.appcelerator.titanium.view.TiUIView.processProperties(TiUIView.java:562)\r\n06-07 16:56:14.105: E\/TiApplication(2738): \tat ti.modules.titanium.ui.widget.TiView.processProperties(TiView.java:39)\r\n..\r\n<\/pre>\n<p>This happens because Titanium recognizes the image as a 9-patch image.<\/p>\n<p>When opening the local image resource, Titanium checks whether it is a 9-patch image in <a href=\"https:\/\/github.com\/appcelerator\/titanium_mobile\/blob\/master\/android\/titanium\/src\/java\/org\/appcelerator\/titanium\/util\/TiNinePatchHelper.java#L62\" target=\"_blank\">TiNinePatchHelper.java<\/a>.<\/p>\n<p>If the 1-pixel edge of the image contains only black and transparent color, it recognizes as a 9-patch image.<\/p>\n<p>So if you want to avoid the error, the border of the image should contain at least one pixel with other color, such as black pixel with a little bit transparency.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you use a image with black border as a background image, this kind of error is occurred in Android. (Related issue : TIMOB-4889) 06-07 16:56:04.507: E\/TiApplication(2738): (KrollRuntimeThread) [438,440] APP PROXY: ti.modules.titanium.app.AppModule@413ba7f8 06-07 16:56:14.105: E\/TiApplication(2738): (main) [1156,8379] Sending event: exception on thread: main msg:java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0; Titanium 2.0.2,2012\/05\/30 10:21,2ff31a3 06-07 16:56:14.105: &hellip; <a href=\"http:\/\/milkdrops.net\/en\/archives\/30\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">[Android] Titanium recognizes image with a black border as a 9-patch image<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12],"tags":[5,15,14,13],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-titanium","tag-android-2","tag-java-lang-indexoutofboundsexception","tag-tininepatchhelper","tag-titanium-2"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/comments?post=30"}],"version-history":[{"count":7,"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":37,"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/posts\/30\/revisions\/37"}],"wp:attachment":[{"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/media?parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/categories?post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/milkdrops.net\/en\/wp-json\/wp\/v2\/tags?post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}