0



テーブルレイアウトで「n」行を生成する際に存在するギャップを減らそうとしています。
行間のスペースを減らす方法を教えてください。また、2 行の間に表示される余分な色 (2 つの編集テキストの背景色) を削除するにはどうすればよいですか?

ここに画像の説明を入力

これが私のActivtyのコードです:

public TableRow tr2;

//starts from below: 

        /*Intent passedvals = getIntent();

        fStoreID = passedvals.getStringExtra("storeID");
        fIMEI = passedvals.getStringExtra("imei");
        fDate = passedvals.getStringExtra("date");*/

        TableLayout tl2 = (TableLayout) findViewById(R.id.dynprodtable);

        String[] ProductID = {"01","02","03","04","05"};
        String[] ProductName = {"Curd50ML","Curd100ML","Milk1LTR","Milk2LTR","Cream250GM"};
        String[] LODqty = {"01Feb-5","01Feb-2","01Feb-10","01Feb-9","01Feb-22"};
        String[] rate = {"10.00","18.00","40.00","75.00","50.00"};
        String[] stock = {"1","2","3","4","5"};
        String[] orderQty = {"1","2","3","4","5"};
        String[] orderVal = {"1","2","3","4","5"};
        String[] freeQty = {"1","2","3","4","5"};
        String[] disVal = {"1","2","3","4","5"};
        //String[] ProductID = {"01","02","03","04","05"};

/*      dbengine.open();
        //productList = dbengine.FetchStoreList();
        dbengine.close();*/

        for (int current = 0; current <= (ProductID.length - 1); current++) {

            // Create a TableRow and give it an ID
            tr2 = new TableRow(this);

            tr2.setId(100 + current);
            tr2.setTag(ProductID[current]);
            //tr2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 10));

            TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            params.setMargins((int)0.0, (int)-50.0, (int)0.0, (int)-50.0);

            tr2.setLayoutParams(params);

            tr2.setClickable(true);

            TextView tvProd = new TextView(this);
            tvProd.setId(200+current);
            tvProd.setTag(ProductID[current]);
            tvProd.setText(ProductName[current]);
            tvProd.setTextSize(8);
            tvProd.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

            tvProd.setBackgroundColor(Color.parseColor("#d8e2ee"));
            tr2.addView(tvProd);

            TextView tvLODqty = new TextView(this);
            tvLODqty.setId(400+current);
            tvLODqty.setTag(ProductID[current]);
            tvLODqty.setText(LODqty[current]);
            tvLODqty.setTextSize(8);
            //tvLODqty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvLODqty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvLODqty.setBackgroundColor(Color.parseColor("#90a3c1"));
            tr2.addView(tvLODqty);

            TextView tvRate = new TextView(this);
            tvRate.setId(500+current);
            tvRate.setTag(ProductID[current]);
            tvRate.setText(rate[current]);
            tvRate.setTextSize(8);
            //tvRate.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvRate.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvRate.setBackgroundColor(Color.parseColor("#90a3c1"));
            tr2.addView(tvRate);

            EditText etStock = new EditText(this);
            etStock.setId(600+current);
            etStock.setTag(ProductID[current]);
            etStock.setText(stock[current]);
            etStock.setTextSize(8);
            //etStock.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            etStock.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            etStock.setBackgroundColor(Color.parseColor("#d8e2ee"));
            tr2.addView(etStock);

            EditText etOrderQty = new EditText(this);
            etOrderQty.setId(700+current);
            etOrderQty.setTag(ProductID[current]);
            etOrderQty.setText(orderQty[current]);
            etOrderQty.setTextSize(8);
            //etOrderQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            etOrderQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            etOrderQty.setBackgroundColor(Color.parseColor("#d8e2ee"));
            tr2.addView(etOrderQty);

            TextView tvOrderVal = new TextView(this);
            tvOrderVal.setId(800+current);
            tvOrderVal.setTag(ProductID[current]);
            tvOrderVal.setText(orderVal[current]);
            tvOrderVal.setTextSize(8);
            //tvOrderVal.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvOrderVal.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvOrderVal.setBackgroundColor(Color.parseColor("#90a3c1"));
            tr2.addView(tvOrderVal);

            TextView tvFreeQty = new TextView(this);
            tvFreeQty.setId(900+current);
            tvFreeQty.setTag(ProductID[current]);
            tvFreeQty.setText(freeQty[current]);
            tvFreeQty.setTextSize(8);
            //tvFreeQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvFreeQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvFreeQty.setBackgroundColor(Color.parseColor("#90a3c1"));
            tr2.addView(tvFreeQty);

            TextView tvDisVal = new TextView(this);
            tvDisVal.setId(1000+current);
            tvDisVal.setTag(ProductID[current]);
            tvDisVal.setText(disVal[current]);
            tvDisVal.setTextSize(8);
            //tvDisVal.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvDisVal.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            tvDisVal.setBackgroundColor(Color.parseColor("#90a3c1"));
            tr2.addView(tvDisVal);

            // Add the TableRow to the TableLayout
            tl2.addView(tr2, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

            /*rb1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub

                    System.out.println("inside-onClick");
                    //System.out.println(arg0.getId());
                    System.out.println(arg0.getTag());
                    selStoreID = arg0.getTag().toString();

                }
            });*/

        }
4

1 に答える 1

0

こんにちは、テーブル行で使用されているパディングが指定されているかどうかを XML ファイルで確認してください。

于 2013-03-02T17:14:13.347 に答える