public class TableLayoutActivity extends the Activity {
TableLayout TableLayout;
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Activity_table_layout);
TableLayout=(tableLayout) the findViewById (R.i which ableLayout01);
TableLayout. SetStretchAllColumns (true);
For (int row=0; Row<6; Row++)
{
TableRow TableRow=new TableRow (TableLayoutActivity. This);
TableRow. SetBackgroundColor (Color, RGB (255, 0, 0));
TextView TV=new TextView (TableLayoutActivity. This);
TV. SetText (" 103451031197 ");
TableRow. AddView (TV);
TextView tv1=new TextView (TableLayoutActivity. This);
Tv1. SetText (" ");
TableRow. AddView (tv1);
TextView tv2=new TextView (TableLayoutActivity. This);
Tv2. SetText (" 30 ");
TableRow. AddView (tv2);
TextView tv3=new TextView (TableLayoutActivity. This);
Tv3. SetText (" 26 ");
TableRow. AddView (tv3);
TextView tv4=new TextView (TableLayoutActivity. This);
Tv4. SetText (" 2 ");
TableRow. AddView (tv4);
TableLayout. AddView (tableRow, new tableLayout. LayoutParams (ViewGroup. LayoutParams. FILL_PARENT, ViewGroup. LayoutParams. WRAP_CONTENT));
}
}
}
& lt; ? The XML version="1.0" encoding="utf-8"?>Android: startColor="# FFFFFF"
Android: endColor="# FFFFFF"
Android: Angle="0"/& gt;Android: width="0.5 dp"
Android: color="# DEDCD2"/& gt;Android: the radius="2 dp/& gt;" The android: left="10 dp"
Android: top="10 dp"
Android: right="10 dp"
Android: bottom="10 dp/& gt;"
CodePudding user response:
& lt; LinearLayout XMLNS: android="http://schemas.android.com/apk/res/android"
XMLNS: tools="http://schemas.android.com/tools"
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Tools: context="com. Example. Tablelayoutactivity. Tablelayoutactivity"
Android: orientation="vertical" & gt;Android: layout_width="fill_parent"
Android: layout_height="45 dp"
Android: gravity="center_vertical" & gt;Android: layout_width="70 dp"
Android: layout_height="wrap_content"
Android: layout_centerVertical="true"
Android: text="loading scan"
Android: textColor="# FFF
"Android: textSize="14 sp/& gt;"Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: layout_centerInParent="true"
Android: text="0"
Android: textColor="# FFFFFF"
Android: textSize="20 sp/& gt;"Android: layout_width="67 dp"
Android: layout_height="wrap_content"
Android: layout_alignParentRight="true"
Android: layout_centerVertical="true"
Android: layout_marginRight="5 dp"
Android: text="jinan express distribution"/& gt;
The android: id="@ + id/TableLayout01"
Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: stretchColumns='*'
Android: background="# DEDCD2" & gt;Android: background="# DEDCD2"
Android: layout_margin="0.5 dip" & gt;Android: text="awb"
Android: textSize="20 dip"
Android: textStyle="bold"/& gt;Android: text="type"
Android: textSize="20 dip"
Android: textStyle="bold"/& gt;Android: text="order"
Android: textSize="20 dip"
Android: textStyle="bold"/& gt;Android: text="scan"
Android: textSize="20 dip"
Android: textStyle="bold"/& gt;Android: text="inventory"
Android: textSize="20 dip"
Android: textStyle="bold"/& gt;
Android: layout_width="match_parent"
The android: orientation="horizontal"
Android: layout_height="50 dp"
Android: background="# aa1885d9"
Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: text="return"/& gt;Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: text="refresh"/& gt;Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: text="submit"/& gt;
Feel still need to improve