Strictly speaking, you are correct, of course. But since the OP said '"layout_width"', not 'layout_width', I assumed he was really thinking about the actual numeric value the width takes, rather than the XML attribute "layout_width". But I did not preserve this distinction in my own writing, so I wrote the wrong thing. Not to mention it was a dubious assumption to begin with, though it did make sense out of his asking for it to be set programmatically, while in his sample XML he was already setting it explicitly.
Of course the real XML attribute "layout_width" is set by the user and used by the layout manager. But this raises a natural question, one I am sure has occurred to many others learning Android: what were they thinking when they named this parameter "layout_width"? Doesn't the very name naturally suggest a numeric value measuring the width, rather than rule for deriving that value from elsewhere? On Jul 9, 1:57 pm, Romain Guy <[email protected]> wrote: > Setting layout_width is NOT the layout manager's job. It's set by the > user to tell the layout manager how to compute the children's > dimensions. > > > > On Fri, Jul 9, 2010 at 1:56 PM, Matt <[email protected]> wrote: > > > On Jul 9, 4:44 pm, Indicator Veritatis <[email protected]> wrote: > >> Let's hope there is a better solution! After all, setting layout_width > >> IS the layout manager's job. > > > Right... and the layout manager does set the width. You can do many > > things: > > > 1. Set the layout_width to "fill_parent" to always have it as wide as > > the screen size. > > 2. Create more than one layout, and put them in different directories > > based on the screen attributes. > >http://developer.android.com/guide/topics/resources/providing-resourc... > > 3. Set the layout_width to a standard size, such as 100dip. Not > > recommended, honestly. > > 4. Use RelativeLayout to set your views positions. > > 5. There's plenty more ways to do it without programmatically setting > > your layout widths, and without knowing exactly what you want to do I > > think the above is good for now. > > > -Matt > > > -- > > 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

