I have a horizontal LinearLayout nested in a vertical LinearLayout nested in a RelativeLayout. It has 5 imageviews which fill the width and I'm using weight to space evenly. I randomly fill between 1 and 5 of the imageviews at runtime. They remain spaced evenly but instead of hugging the left side of the parent, which I read in the docs is the default, they hug the right. I've tried gravity:left and scaleType="fitStart". I've tried nesting this layout in another relative layout and using alignParentLeft. Using a RelativeLayout instead of the LinearLayout will align the images to the left but doesn't space them evenly so isn't an option.
Below are the relevant pieces of my XML file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Game1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="7">
<LinearLayout
android:id="@+id/animal_images_row1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dip"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
>
<ImageView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:id="@+id/block1"
android:contentDescription="@string/ph"
android:scaleType="centerInside"
/>
<ImageView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:id="@+id/block2"
android:contentDescription="@string/ph"
android:scaleType="centerInside" />
<ImageView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:id="@+id/block3"
android:contentDescription="@string/ph"
android:scaleType="centerInside"/>
<ImageView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:id="@+id/block4"
android:contentDescription="@string/ph"
android:scaleType="centerInside" />
<ImageView
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:id="@+id/block5"
android:contentDescription="@string/ph"
android:scaleType="centerInside" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
I removed the rest of the xml file for brevity. Thanks in advance for the help!
EDIT: Add screen shots.
Thanks for the comments! Every little insight helps =) I couldn't figure out why they were sticking to the right and nothing I would do could force them to the left and it turns out that in my code I had
as a temporary fix while I was figuring the layout out and after removing that line they stuck to the left properly.