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

Reply via email to