Didn't realise that you can simply replace WRAP_CONTENT with a fixed width. Problem solved.
On Wednesday, 11 July 2012 20:24:31 UTC+1, marcpolo wrote: > > Hi, > > I'd like to have two views within a horizontal linear layout and > programatically align them as follows. > > View A should be of fixed width on the left hand side and View B should > fill the remainder of the space. I tried setting the following layout > parameters > > ViewA.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, > LayoutParams.MATCH_PARENT, 0)); > ViewB.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, > LayoutParams.MATCH_PARENT, 1)); > > Whenever I set the weight of ViewA to 0, only ViewA is displayed. I > expected a value of 0 to mean that ViewA doesn't get stretched. > > When I set ViewA::Weight = 4, and ViewB::Weight = 1, ViewA is a quarter of > the size of ViewB. I expected the reverse. > > WRAP_CONTENT seems to have no effect. > > This seems straightforward when using the manifest file, however I am > modifying existing code that requires me to set these values > programatically. Could someone help me. > > Thanks in advance. > -- 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