I’m trying to use a NinePatch image, stretched horizontally.
I haven’t used NinePatch much, but do have other NinePatches images working in other areas (e.g., as background of of Views with content), as expected.
I’ve attached a simplified version of what I’m experiencing. Basically I want the dot to tile the center pixel horizontally. The image will only ever expand horizontally. It does not contain any other views.
I first tried setting just a single-pixel vertical path, then added a single-pixel horizontal path as well. No difference. In the preview panel of the NinePatch tool, it appears fine.
It’s being used in a RelativeLayout, per the code sample below. I’ve included lines that are commented out as other settings I’ve tried.
track = new ImageView(context);
track.setScaleType(ScaleType.FIT_XY);
//track.setScaleType(ScaleType.FIT_CENTER);
track.setBackgroundResource(R.drawable.bg_track);
//track.setImageResource(R.drawable.bg_track);
LayoutParams trackLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//LayoutParams trackLayout = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
trackLayout.addRule(RelativeLayout.CENTER_VERTICAL);
trackLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
trackLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
addView(track, trackLayout);

I’m sure I’m missing something simple, but can’t figure it out.
Any insights are appreciated.
TYIA.
you misunderstood Ninepatch concept. try to understand by this image
You can also try with this BetterNinePatch tool http://android.elex.pe.kr/a-better-9-patch-tool 🙂
try to create like this.