Need Help with the android:weightSum and layout_weight attributes

by Business Talk » Thu, 26 Nov 2009 20:43:10 GMT


Sponsored Links
 I have a simple horizontal linear_layout  with bunch of image views in
it. the trick is that the views have different widths, relative to the
size of their parent (the linear layout). I set the layout's weightSum
to a 100 and the layout_weight to let's say 10 of one view and 15 of
the other, on so on. And it did not work. I also tired using float
values setting the weightSum to 1.0 and the layout_weight of the image
views to 0.2 and 0.3 and so on. But it didn't work either. I did
search this group for any references to the weightSum but found
nothing. Any ideas how to handle it?

--



Need Help with the android:weightSum and layout_weight attributes

by Romain Guy » Fri, 27 Nov 2009 01:41:51 GMT


 Hi,

What doesn't work exactly? What are you trying to do and what is the result?

On Thu, Nov 26, 2009 at 4:42 AM, Business Talk


>


Sponsored Links


Need Help with the android:weightSum and layout_weight attributes

by steelbytes » Fri, 27 Nov 2009 09:16:25 GMT


 I think you have to set the width of each item to 0px. then the
weighting will override this?  seems to work for me.

It's a shame that the docs are so spartan.




> >



Need Help with the android:weightSum and layout_weight attributes

by Romain Guy » Fri, 27 Nov 2009 09:39:06 GMT


 Using 0px is mostly an optimization. It is not required.




I think you have to set the width of each item to 0px. then the
weighting will override this?  seems to work for me.

It's a shame that the docs are so spartan.



doesn't work exactly? W...



linear_layout  with bunch of ...

to provide private suppo...
text -

--



Need Help with the android:weightSum and layout_weight attributes

by Business Talk » Fri, 27 Nov 2009 20:56:13 GMT


 Thanks to all, it worked. You can only guess how much time you saved
me. Good Luck






>



Other Threads

1. How to control the width of scrollbars for DatePick?

Is there a way to control the width of the three scrollbars for
DatePick?

I wanted to make the following layout, but the default setup can't fit
into the screen. I think there might be a way to control the width of
the scrollbar so that the two DatePick can fit into the screen.

        <LinearLayout android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">
                <DatePicker  android:id="@+id/from_date"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >
                </DatePicker>
                <DatePicker android:id="@+id/to_date"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >
                </DatePicker>
    </LinearLayout>

Did anyone try to solve this problem before?
Thanks,
--~--~---------~--~----~------------~-------~--~----~

2. Can I put multiple selector nodes in one xml file and reference them from layout xml file?

Not directly, that's not how the standard widgets are supposed to work.  You
could easily make your own custom subclass of button, though, that had three
attributes for the three different drawables and created a state list
drawable itself from them.  Then you could have everything in your single
layout file.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

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.

--~--~---------~--~----~------------~-------~--~----~

3. How to draw the route for maps

4. How to keep the selected item highlighted when menu button is clicked?

5. How to keep the selected item highlighted when menu button is clicked?

6. Necessity of Map API Key

7. Can I put multiple selector nodes in one xml file and reference them from layout xml file?