gridlayout

The component will be placed in a square, so it is not suitable for placing the JButton such component, and is more suitable to join JPANEL. The information of the GIRDLAYOUT class is as follows:

public class gridLayout Extends Object IMPLEMENTS LAYOUTMANAGER, Serializable

Constructor

Public GridLayout

gridlayout

Public GridLayout INT ROWS, INT Cols;

Public GridLayout (int ROWS, INT COLS, INT HGAP, INT VGAP);

function effect: create a table's layout object. Rows represents a few lines, and the cols represents several columns; HGAP is the horizontal distance between components, and VGAP is the vertical distance of the components

Features:

GridLayout layout Using virtual The thin line divides the layout into rows, columns, and cells, and also supports a control in line, and there are interlaced arrangements. GridLayout is actually a similar API similar to LinearLayout, but it is only a revised label, so for developers, master GridLayout is still very easy. GridLayout's layout strategy is simple to divide into the following three parts:

First of all, it is divided into two ways and vertical layout, which is divided into horizontal and vertical ways. The default is horizontal layout, one control is next control from left to left Right is arranged in turn, but by specifying the attributes of the column number by specifying Android: ColumnCount, the control will automatically go out. On the other hand, for the sub-control in the GridLayout layout, the default is set according to the WRAP_CONTENT, which only needs to explicitly declare the "secondary declaration in the GridLayout layout. To specify a control display at fixed Rows or columns, just set the Android: layout_row and Android: layout_column properties of the child control, but you need to pay attention: Android: layout_row = "0" means starting from the first row, Android: layout_column = "0" means The first column begins, which is similar to the assignment of one-dimensional array in the programming language.

Finally, if you need to set a control across multiple lines or multiple columns, simply set the Android: layout_rowspan or layout_columnspan property to set, then set its layout_gravity attribute to Fill, the previous one The setting indicates the number of rows or columns of the control, and the latter setting indicates that the control fills the entire line or whole.

Related Articles
TOP