I didn't know about that method, but that sounds like the right
solution. I was kind of suspecting that there would be a cleaner
solution to all of this.

Thank you for your advice.

// Anders

On 13 Okt, 09:36, Dianne Hackborn <hack...@android.com> wrote:
> I very very strongly recommend not creating a nine patch yourself; just use
> Resources.getDrawable() to create it.
>
>
>
> On Tue, Oct 13, 2009 at 12:02 AM, Anders <sundman.and...@gmail.com> wrote:
>
> > Ah! That works fine, thank you very much.
>
> > As to why I was creating a NinePatchDrawable my self... I can only
> > claim inexperience with the NinePatch classes. :)
>
> > This is how it looks now, after your comments:
>
> > Bitmap tagBalloonBitmap = BitmapFactory.decodeResource(getResources(),
> > R.drawable.balloon);
> > NinePatchDrawable tagBalloon9pDrawable =
> >                        new NinePatchDrawable(tagBalloonBitmap,
>
> >  tagBalloonBitmap.getNinePatchChunk(),
> >                                        new Rect(0,0,0,0), null);
>
> > // Anders
>
> > On 13 Okt, 00:01, Romain Guy <romain...@google.com> wrote:
> > > BTW, why are you creating the NinePatchDrawable yourself if you are
> > > creating it from a resource anyway?
>
> > > On Mon, Oct 12, 2009 at 3:01 PM, Romain Guy <romain...@google.com>
> > wrote:
> > > > NinePatchDrawable tagBalloon9pDrawable = new
> > NinePatchDrawable(tagBalloon9p);
>
> > > > this creates a NinePatchDrawable with a null padding. That's why you
> > > > get an NPE. You need to specify the padding.
>
> > > > On Mon, Oct 12, 2009 at 10:07 AM,Anders<sundman.and...@gmail.com>
> > wrote:
>
> > > >> I'm trying to use NinePatchDrawables in a LayerDrawable, but for some
> > > >> reason I get a NullPointerException. I've isolated the problem to the
> > > >> getPadding() method; the following code reproduces the problem:
>
> > > >> Bitmap tagBalloonBitmap = BitmapFactory.decodeResource(getResources(),
> > > >> R.drawable.balloon);
> > > >> NinePatch tagBalloon9p = new NinePatch(tagBalloonBitmap,
> > > >> tagBalloonBitmap.getNinePatchChunk(), null);
> > > >> NinePatchDrawable tagBalloon9pDrawable = new NinePatchDrawable
> > > >> (tagBalloon9p);
>
> > > >> Rect r = new Rect();
> > > >> tagBalloon9pDrawable.getPadding(r);  <<-- Throws NullPointerException!
>
> > > >> What am I missing? Do I have to do anything special with the
> > > >> NinePatch? The program seems to work if I use the NinePatch directly
> > > >> (instead of putting it in a LayerDrawable).
>
> > > >> Any suggestions and help is greatly appreciated.
>
> > > >> //Anders
>
> > > > --
> > > > Romain Guy
> > > > Android framework engineer
> > > > romain...@android.com
>
> > > > Note: please don't send private questions to me, as I don't have time
> > > > to provide private support.  All such questions should be posted on
> > > > public forums, where I and others can see and answer them
>
> > > --
> > > Romain Guy
> > > Android framework engineer
> > > romain...@android.com
>
> > > Note: please don't send private questions to me, as I don't have time
> > > to provide private support.  All such questions should be posted on
> > > public forums, where I and others can see and answer them
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to