Can someone please explain what GridLayout’s rowOrderPreserved and columnOrderPreserved mean?
I don't understand the docs. What is the difference between setting the value to true or false. An illustration wil be very helpful.
Consider the following piece of code with GridLayout:
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:useDefaultMargins="true"
android:alignmentMode="alignBounds"
android:columnOrderPreserved="true"
android:columnCount="4"
>
<TextView
android:text="Email setup"
android:textSize="32dip"
android:layout_columnSpan="4"
android:layout_gravity="center_horizontal"
/>
<TextView
android:text="Email address:"
android:layout_gravity="left"
/>
<EditText
android:ems="10"
/>
<TextView
android:text="Password:"
android:layout_column="0"
android:layout_gravity="right"
/>
<EditText
android:ems="8"
/>
<Button
android:text="Next"
android:layout_row="4"
android:layout_column="3"
/>
</GridLayout>
This xml generates a view as follows in which the 'Next'-button is outside of the screen:

This is because the first EditText element defines the width of the second column. When defining the 'Next' button in the fourth column, it has to be right of the second column.
Now, changing the attribute columnOrderPreserved to false gives android the liberty to place the horizontal column boundaries in whatever order best fits the given constraints. (See the documentation) The result is as in this image:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With