I've read plenty of questions saying that the problem was the layout_width = 0dip
but I've tried that and can't make this work.
I have this holder:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/linearLayout1"
android:orientation="horizontal"
android:weightSum="3"
android:padding="10dip"
android:fadingEdge="none"
android:background="@drawable/bg_filters">
</LinearLayout>
And this partials:
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="0dip"
android:layout_height="40dip"
android:padding="4dip"
android:gravity="center"
android:layout_gravity="center"
android:layout_weight="1"
android:layout_marginRight="15dip"
android:background="@drawable/bg_filter_bt_active"
android:textColor="@color/app_color_all">
</Button>
but my views' buttons show still show up grouped to the left... Is there a method I should call the holder to recalculate the weights of its children?
Remember, I'm creating them programmatically.
Thanks !
EDIT:
I already HAVE a screen with this composition:
##################################
# #
# Button | Button | Button #
# #
with that exact XML, but instead of being created programmatically, it is already there in the XML. It works perfectly.
When I create the same setup but programmatically, I get this:
##################################
# #
# Button | Button | Button #
# #
The buttons align themselves to the left, even tho the weight should evenly distribute them.
Is there a method or something I need to call to the LinearLayout
to calculate the weight and correct the view?
EDIT 2:
I just tried taking this same LinearLayout
and inserting the same Button
3 times inside it on a regular XML. It shows just like it should. This is definitely something to do with creating the holder and the 3 buttons programmatically.