我在按钮单击事件中添加了一个表格行。我的行有2个textview和2个spinners和1个EditText。我希望列的大小相同,但是微调控件的大小会根据所选值更改。请帮助,并分享一些灯。如何保持表列的大小与安卓视图无关
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableLayout
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:stretchColumns="*"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_weight=".2"
android:background="@drawable/cell_shape"
android:padding="5dp"
android:text="S.No"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium"></TextView>
<TextView
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_weight=".2"
android:background="@drawable/cell_shape"
android:padding="5dp"
android:text="Product"
android:textAppearance="?android:attr/textAppearanceMedium"></TextView>
<TextView
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@drawable/cell_shape"
android:layout_weight=".2"
android:padding="5dp"
android:text="Product List"
android:textAppearance="?android:attr/textAppearanceMedium"></TextView>
<TextView
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@drawable/cell_shape"
android:layout_weight=".2"
android:padding="5dp"
android:text="Price"
android:textAppearance="?android:attr/textAppearanceMedium"></TextView>
<TextView
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@drawable/cell_shape"
android:layout_weight=".2"
android:padding="5dp"
android:text="Quantity"
android:textAppearance="?android:attr/textAppearanceMedium"></TextView>
</TableRow>
<!--<TableRow
android:id="@+id/tr1"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"/>-->
</TableLayout>
<TableLayout
android:id="@+id/tlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</TableLayout>
</LinearLayout>
<Button
android:id="@+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Add Item"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"><Button
android:id="@+id/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
/></LinearLayout>
</LinearLayout>
在此先感谢
你可以添加布局的XML ?,它会更容易帮助你。 – kevinkl3
我已经添加了xml布局 –
您是否以编程方式添加新行?如果是这种情况,你是否使用布局和LayoutInflater? – kevinkl3