Last Updated: February 25, 2016
·
1.619K
· outlying

Working 9-patch images from assets ( or any other location )

Using 9-patch images is a great way to quickly create nice application UI.

However, (uncrunched) 9-patch images created with draw9patch tool will not work if you try to load them from assets or any other internal or external location. You have to put them in one of resources drawable directory.

To solve this issue you have to run this command ( output directory have to be created earlier ):

aapt c -S /dir_with_uncrunched_9patch/ -C ./output_dir/

Now you have crunched version of your 9-patch images, you may keep them, and use them, anywhere you want.