I'm fairly new to android's xml but I have been having some trouble with the grid layout. All I want is for all the buttons in a grid to be evenly spaced from each-other with the two top center most buttons sharing a border. This is the code I have so far:
<GridLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="4" android:rowCount="5" android:alignmentMode="alignBounds" android:layout_weight="1"> <LinearLayout android:id="@+id/select_box" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="1" android:layout_row="0" android:layout_columnSpan="2" android:layout_gravity="top" android:layout_columnWeight="0" android:background="@drawable/selected_border_one"> <Button android:id="@+id/selected_text_one" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_gravity="center" android:text="TYPE 1" android:textColor="@color/trueBlack" android:background="#999999" android:onClick="selecSelection"> </Button> <Button android:id="@+id/selected_text_two" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_toRightOf="@id/selected_text_one" android:layout_gravity="center" android:text="TYPE 2" android:textColor="@color/trueBlack" android:background="#555555" android:onClick="selectSelection"> </Button> </LinearLayout> <Button android:id="@+id/ground_but" android:layout_width="0dp" android:layout_height="0dp" android:layout_row="4" android:layout_column="0" android:layout_columnWeight="1" android:layout_rowWeight="1" android:layout_gravity="fill" android:background="@color/groundBrown" android:text="@string/ground_string" android:onClick="setType"/> ... Rest of the buttons The outcome of this is: can be seen at http://i.imgur.com/r4FGM4C.png because apparently since my account is new I cant post images.
As you can see (assuming you looked at the picture) the third column is taking over some of the second column's space. If I remove the linear layout holding the two buttons with the border then everything is spaced properly, but I can't figure out why adding it in changes the weights. Any help will be greatly appreciated and thank you in advanced.
No comments:
Post a Comment