No, that won't work because the 4 views will expand to take up the
extra room, leaving the ImageButtons only as wide as their layout
width of 50px.  I don't want that.  I want the buttons to expand to
take up that room.

On Nov 6, 8:13 am, Kostya Vasilyev <[email protected]> wrote:
> Don't set layout_weight=1 on the buttons.
>
> Insert four Views between the buttons to act as spacers, and give those
> layout_weight:
>
> <ImageButton..../>
>
> <View
> android:layout_width="0px"
> android:layout_height="1px"
> android:layout_weight="1"/>
>
> <ImageButton.../>
>
> <View
> android:layout_width="0px"
> android:layout_height="1px"
> android:layout_weight="1"/>
>
> etc.
>
> -- Kostya
>
> 06.11.2011 17:09, RLScott пишет:
>
>
>
>
>
> > This should be easy, but everything I try is not quite right.  I want
> > to use an XML RelativeLayout to position 5 square ImageButtons along
> > the bottom of the screen.  The images are defined by a 120 x 120 pixel
> > PNG, so it needs to be scaled down to fit in a Droid in portrait mode,
> > for instance.  I have tried specify for each button:
>
> >    android:layout_weight="1"
> >    android:layout_width="50px"
> >    android:layout_height="50px"
> >    android:scaleType="fitXY"
>
> > The layout_weight="1" is necessary to make the buttons spread out
> > horizontally and share the space.  Otherwise they bunch up at the
> > beginning.
>
> > The layout_width and layout_height are arbitrary, but they are
> > necessary to keep the program from crashing.
>
> > the scaleType of "fitXY" is necessary to make the image scale down to
> > the laid out size of the button.   But it only scales in X.  It leaves
> > Y at 50px because that was my arbitrary setting.  I want the
> > ImageButton to remain square, so I need the X and Y sizes to be the
> > same.  I don't know how to do that in XML without specifying them
> > explicitly, and I don't want to do that because I want the X sizes to
> > be set by dividing up the available width evenly in the layout
> > process.  I am willing to do some adjustments in onCreate, but what
> > can I do to force the 1:1 aspect ratio of the buttons and still
> > benefit from convenience of XML layout?
>
> --
> Kostya Vasilyev

-- 
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