No, the bounds are where the drawable will actually render itself. If you want two different bounds, that should technically be two different drawables.
If you need to have this all in one drawable, the only option I can think of is to make your own subclass of Drawable that computes the different bounds as you want them. On Mon, Jul 30, 2012 at 9:44 AM, Jonathan Koren <[email protected]> wrote: > I'm creating a custom View that looks like a horizontal ProgressBar but > doesn't always have to touch the left edge. My approach is to use a > LayerDrawable in which one layer uses different bounds (computed at run > time). The attachement shows expected (top) versus actual (bottom) results. > > From what I can tell, setting the bounds for one layer also sets the > bounds for the entire LayerDrawable. The code in the custom View is > essentially this: > > int left, top, right, bottom; > /*... do some math ... */ > Drawable d = mDrawable.findDrawableByLayerId(R.id.custom_layer_id); > d.setBounds(left, top, right, bottom); > > > Meanwhile, the xml for the drawable is this: > > <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > > > <item> > > <shape android:shape="rectangle" > > > <solid android:color="#ff999999" /> > > </shape> > > </item> > > <item > > android:id="@id/custom_layer_id" > > android:drawable="@drawable/test_gradient"/> > > </layer-list> > > > Can I set bounds for an individual layer without affecting the other > layers? If not, what can I do to get around this issue? > > -- > 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 -- Dianne Hackborn Android framework engineer [email protected] 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 [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

