the createFromStream()
method is part of the Drawable class (which NinePatchDrawable extends) So it is returning to you a plain Drawable object, rather than a nine patch. That is why your button turns out looking that way I suspect.
Where is the image that you are trying to make in to a nine-patch? It seems from your example that it may be included in with your application resources (perhaps in one of the drawable folders?) if this is the case is there a reason that using the ID of the drawable will not work for your situation? you should be able to do something like this:
button.setBackgroundResource(R.drawable.btn_default_normal);
If I am missing something(which I definitely could be.) and there is a reason you can't use the resource ID. From the docs it looks like your second block of code is closer to what you'll want.
But the constructor you're using is deprecated. Try using this one instead. which would look like this:
InputStream in = MyClass.class.getResourceAsStream("/images/btn_default_normal.9.png");
Bitmap bitmap = BitmapFactory.decodeStream(in);
byte[] chunk = bitmap.getNinePatchChunk();
NinePatchDrawable drawable = new NinePatchDrawable(getResources(), bitmap, chunk, new Rect(), null);
button.setBackgroundDrawable(drawable);
The only difference being the first paramter should be your Applications Resources object.
However, honestly I could've sworn I read somewhere at some point that the system was incapable of working with NinePatchDrawables dynamically as objects. Even though the NinePatchDrawable object exists, I was under the impression that it was not working / not intended to be part of the public APIs
EDIT:
Does the answer on this question help? Create a NinePatch/NinePatchDrawable in runtime
Also my answer at the bottom of that question reminds me exactly why I was under the impression that it was not working / not indeded for part of the public APIs the docs for the getNinePatchChunk say
Returns an optional array of private data, used by the UI system for some bitmaps. Not intended to be called by applications.
But it looks like they managed to get it working anyway.