- android:layout_toRightOf="@id/label". - android:layout_alignParentTop="true"/>. - android:id="@+id/ok". - android:layout_width="wrap_content". - android:layout_height="wrap_content". - android:layout_below="@id/entry". - android:layout_alignRight="@id/entry". - android:text="OK". - android:id="@+id/cancel". - android:layout_toLeftOf="@id/ok". - android:layout_alignTop="@id/ok". - android:text="Cancel". - TableLayout controls the overall behavior of the container, with the widgets themselves poured into one or more TableRow containers, one per row in the grid.. - However, a widget can take up more than one column by including the android:layout_span property, indicating the number of columns the widget spans. - <TextView android:text="URL:". - android:id="@+id/entry". - android:layout_span gt;. - However, you can put a widget into a different column via the android:layout_column property, specifying the 0-based column the widget belongs to:. - android:layout_column . - <Button android:id="@+id/ok". - For example, you could use <View android:layout_height = "2px". - android:background FF". - for a 2-pixel-high blue bar across the width of the table.. - By default, each column will be sized according to the natural size of the widest widget in that column (taking spanned columns into account). - You can place an android:stretchColumns property on the TableLayout. - Those columns will be stretched to take up any available space on the row.. - Conversely, you can place a android:shrinkColumns property on the TableLayout . - The columns listed in this property will try to word-wrap their contents to reduce the effective width of the column. - This helps if you have columns with potentially wordy content that might cause some columns to be pushed off the right side of the screen.. - You can also leverage an android:collapseColumns property on the TableLayout, again with a column number or comma-delimited list of column numbers. - These columns will start out collapsed, meaning that they will be part of the table information but will be invisible. - Programmatically, you can collapse and uncollapse columns by calling setColumnCollapsed() on the TableLayout . - The XML layout fragments shown earlier, when combined, give us a TableLayout rendition of the form we created for RelativeLayout, with the addition of a divider line between the label/field and the two buttons (found in the Containers/Table demo):. - xmlns:android="http://schemas.android.com/apk/res/android". - android:layout_width="fill_parent". - android:layout_height="fill_parent". - <TextView. - android:text="URL:". - <EditText android:id="@+id/entry". - android:layout_height="2px". - android:background="#0000FF". - <Button android:id="@+id/cancel". - <Button android:id="@+id/ok". - use scrolling, so only part of the information is visible at one time, and the rest is available via scrolling up or down.. - android:layout_height="wrap_content">. - android:layout_height="80px". - android:background gt;. - <TextView android:text . - android:layout_gravity="center_vertical". - android:background . - android:background="#aa8844". - <TextView android:text="#aa8844". - android:background="#ffaa88". - <TextView android:text="#ffaa88". - android:background="#ffffaa". - <TextView android:text="#ffffaa". - android:background="#ffffff". - <TextView android:text="#ffffff". - Notice how only five rows and part of the sixth are visible. - Also note how the right side of the content is clipped by the scrollbar
Xem thử không khả dụng, vui lòng xem tại trang nguồn hoặc xem
Tóm tắt