Reputation: 2910
How to set the space left over to be divided equally?
For example, I have a GridView with 2 columns. The full width is 700px, and the column is 200px: how do I specify the xml, so the space left (300px) are divided evenly into 3 pieces?
i.e. 100px | 200px (Column 1) | 100px | 200px (Column 2) | 100px
Upvotes: 7
Views: 9298
Reputation: 2383
Alternatively you could use android.support.v7.widget.GridLayout
as such
<android.support.v7.widget.GridLayout app:columnCount="5">
<Space app:layout_columnWeight="1>
<View>
<Space app:layout_columnWeight="1"/>
<View>
<Space app:layout_columnWeight="1>
</android.support.v7.widget.GridLayout>
to achieve the desired effect, unless you are building exclusively for SDK 21, and then use the normal GridLayout
Upvotes: 1
Reputation: 1675
Set the android:stretchMode
to spacingWidthUniform
.
http://developer.android.com/reference/android/widget/GridView.html#attr_android:stretchMode
Upvotes: 13