Search code examples
androidimagenine-patch

stretching only one axis with 9patch


So I have pictures I only want to stretch via the nine patch functionality along one axis like this one:

sample image

As you can see there's not a lot of room on the sides so I can't stretch along the x axis without it becoming noticeable. Instead I'm programmatically setting the width to the appropriate size (with this portrait version) and using the indicated regions along the y axis to fit to screen.

The problem is I keep getting this log output on build.

AAPT out(164205) : No Delegate set : lost message:Done AAPT out(8577269) : No Delegate set : lost message:Done AAPT err(164205): ERROR: 9-patch image C:\Users\Brandon Thompson\AndroidStudioProjects\TilePuzzler\app\src\main\res\drawable\star_trek_federation_emblem_land9patch.9.png malformed. AAPT out(24044720) : No Delegate set : lost message:Done AAPT err(164205): No marked region found along edge. AAPT err(8577269): ERROR: 9-patch image C:\Users\Brandon Thompson\AndroidStudioProjects\TilePuzzler\app\src\main\res\drawable\star_wars_imperial_emblem_port9patch.9.png malformed. AAPT err(164205): Found along left edge. AAPT err(24044720): ERROR: 9-patch image C:\Users\Brandon Thompson\AndroidStudioProjects\TilePuzzler\app\src\main\res\drawable\star_trek_federation_emblem_port9patch.9.png malformed. AAPT err(8577269): No marked region found along edge. AAPT err(24044720): No marked region found along edge. AAPT err(8577269): Found along top edge. AAPT err(24044720): Found along top edge. AAPT out(22973825) : No Delegate set : lost message:Done AAPT err(22973825): ERROR: 9-patch image C:\Users\Brandon Thompson\AndroidStudioProjects\TilePuzzler\app\src\main\res\drawable\star_wars_imperial_emblem_land9patch.9.png malformed. AAPT err(22973825): No marked region found along edge. AAPT err(22973825): Found along left edge. Error:Execution failed for task ':app:mergeDebugResources'. Crunching Cruncher star_wars_imperial_emblem_port9patch.9.png failed, see logs

This would seem to indicate that I must designate some of my unavailable area on the x axis, but I was under the impression that you could set it to stretch only what you wanted. Was that impression in error or am I missing something else? Would it be possible to simply designate the entire x axis to ensure uniform stretching? Thanks.


Solution

  • As it turns out 9patch images insist on having some black marks in the left and top margins. By drawing a line along the entire side I didn't want stretched in segments I ensured an even expansion.