[TIMOB-10396] TiAPI: 9-patch workflow enhancements
GitHub Issue | n/a |
Type | New Feature |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 2.1.1 |
Fix Version/s | n/a |
Components | Android |
Labels | community, core |
Reporter | Esben Maaløe |
Assignee | Unknown |
Created | 2012-08-06T08:51:56.000+0000 |
Updated | 2018-02-28T20:03:19.000+0000 |
Description
backgroundImage : 'test.png'
Android will look for the image. If it can't find it, it will look for 'test.9.png'
I suggest the opposite
Android first looks for test.9.png, if it can't find it, it will look for 'test.png'
That way you don't need any branching code in your app if you are writing for Android and iOS simultaneously
Instead of:
backgroundImage : Ti.Platform.osname == 'android' ? 'test.png' : 'test_ios.png'
you could simply go:
backgroundImage : 'test.png'
Here is some testcode. Copy the attached images to the root of Resources/ - then build. You'll clearly see that Android is using 'test.png' stretched raw, rather than using 'test.9.png'.
Then delete or rename test.png, and build again (you may or may not need to clean project) and build again - now it works.
~~~
var win = Ti.UI.createWindow(
{
backgroundColor : 'white',
exitOnClose : true,
fullscreen : false,
title : 'Click button to test'
});
var button = Ti.UI.createButton(
{
backgroundImage : '/test.png',
backgroundSelectedImage : '/test.png',
title : 'Click me!',
top : 10,
width : 300,
height : 200
});
button.addEventListener('click', function(e) {
Ti.API.info("You clicked the button");
});
win.add(button);
win.open()
~~~
Attachments
File | Date | Size |
test.9.png | 2012-08-06T08:51:56.000+0000 | 348 |
test.png | 2012-08-06T08:51:56.000+0000 | 352 |
No comments