Without seeing your code it's hard to know what's going on, but
background drawables are never drawn in the foreground.

On Sat, Feb 6, 2010 at 11:39 AM, Bob Kerns <[email protected]> wrote:
> The right thing to do is to adjust your 9patch with the 9patch tool to
> indicate what the padding should be. Those are those pixels on the
> right and bottom.
>
> I haven't actually tried setting them to be wider than the stretchable
> area, but I'd expect it to work.
>
> But the other issue I've found is that it seems it doesn't actually
> draw 9PatchDrawables in the background, but rather the foreground!
> Thus, my translucent stretchable area was being drawn on top of my
> window content. I made that transparent, but the actual background in
> another layer behind the content as a graphic. It makes sort of a
> twisted sense, but:
>
> 1) It's not documented
> 2) It's so counterintuitive I consider it a bug on those grounds
> alone.
>
> The twisted sense that it makes is that it enables using the
> background with a 9patch to implement borders with clipping, by
> drawing them on top of the content. And, in fact, moving the graphic
> to the background DID result in content on top of border.
>
> But Jeez, Louise....don't use background to draw in the foreground!
>
> On Feb 6, 10:31 am, Mark Nuetzmann <[email protected]> wrote:
>> After a quick search I saw some comments of "what not to do"... but in
>> my case it WORKED PERFECT.  Rather than setting the layout background
>> in the xml as I had originally done (and what I would have preferred
>> to do). I took a little of the code from another post and set the
>> background in code.  This worked awesome.
>>
>>         Bitmap bkBitmap = BitmapFactory.decodeResource(getResources(),
>> R.drawable.content_bg);
>>         NinePatchDrawable bkDrawable = new NinePatchDrawable(bkBitmap,
>> bkBitmap.getNinePatchChunk(),  new Rect(0,0,0,0), null);
>>         bkDrawable.setAlpha(96);
>>
>> findViewById(R.id.content_container).setBackgroundDrawable(bkDrawable);
>>
>> When I do this the LinearLayout is getting a padding rect of (0,0,0,0)
>> from its background and lays out its child views like normal; exactly
>> what I wanted.  The background 9-patch now acts only as a background
>> rather than a constraint on the contents of the LinearLayout.
>>
>> Regards,
>> Mark
>>
>> On Feb 6, 12:15 pm, Mark Nuetzmann <[email protected]> wrote:
>>
>>
>>
>> > I have a LinearLayout that I set a background to a 9-patch drawable.
>> > It appears that the LinearLayout is somehow forcing its contents to
>> > display within the center space defined by its background.  This is
>> > really creating problems as the content is being "scrunched" or
>> > compressed to a much smaller space that what I anticipated.  I do not
>> > have any margins or padding set on the LinearLayout so I know the only
>> > place it could be getting this is from the background.  All I wanted
>> > was for the background to be a background and not some how contribute
>> > to how the LinearLayout laid out its views.  Is there a way to tell
>> > the LinearLayout NOT to pull sizing information from its background?
>> > I see that the class NinePatchDrawable has a getPadding() but NO
>> > setPadding().  I assume that the LinearLayout is getting the padding
>> > from NinePatchDrawable and using that to contrain the contents of the
>> > layout to a smaller area.  Can I override this without subclassing
>> > this class?
>>
>> > Regards,
>> > Mark
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Romain Guy
Android framework engineer
[email protected]

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

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to