共用方式為


GridLayout.Orientation Property

Definition

Returns the current orientation. -or- GridLayout uses the orientation property for two purposes: <ul> <li> To control the 'direction' in which default row/column indices are generated when they are not specified in a component's layout parameters.

public virtual Android.Widget.GridOrientation Orientation { [Android.Runtime.Register("getOrientation", "()I", "GetGetOrientationHandler")] get; [Android.Runtime.Register("setOrientation", "(I)V", "GetSetOrientation_IHandler")] set; }
[<get: Android.Runtime.Register("getOrientation", "()I", "GetGetOrientationHandler")>]
[<set: Android.Runtime.Register("setOrientation", "(I)V", "GetSetOrientation_IHandler")>]
member this.Orientation : Android.Widget.GridOrientation with get, set

Property Value

either #HORIZONTAL or #VERTICAL

Attributes

Remarks

Property getter documentation:

Returns the current orientation.

Java documentation for android.widget.GridLayout.getOrientation().

Property setter documentation:

GridLayout uses the orientation property for two purposes: <ul> <li> To control the 'direction' in which default row/column indices are generated when they are not specified in a component's layout parameters. </li> <li> To control which axis should be processed first during the layout operation: when orientation is #HORIZONTAL the horizontal axis is laid out first. </li> </ul>

The order in which axes are laid out is important if, for example, the height of one of GridLayout's children is dependent on its width - and its width is, in turn, dependent on the widths of other components.

If your layout contains a TextView (or derivative: Button, EditText, CheckBox, etc.) which is in multi-line mode (the default) it is normally best to leave GridLayout's orientation as HORIZONTAL - because TextView is capable of deriving its height for a given width, but not the other way around.

Other than the effects above, orientation does not affect the actual layout operation of GridLayout, so it's fine to leave GridLayout in HORIZONTAL mode even if the height of the intended layout greatly exceeds its width.

The default value of this property is #HORIZONTAL.

Java documentation for android.widget.GridLayout.setOrientation(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also