Как установить Margin для представлений в TableRow в TableLayout? - PullRequest
0 голосов
/ 09 сентября 2018

Я добавляю 9 кнопок в 3 строки и 3 столбца с помощью tableLayout, но я не могу установить поля для этих кнопок, пожалуйста, проверьте мой код и, если возможно, направьте меня. Спасибо.

    tableBoard = findViewById(R.id.board_table);
    tableBoard.setStretchAllColumns(true);


    int counter = 1;
    for (int i = 0; i < 3; i++) {
        TableRow tableRow = new TableRow(this);

        for (int j = 0; j < 3; j++) {
            Button button = new Button(MainActivity.this);

            button.setOnClickListener(this);
            button.setTag(counter);

            button.setBackground(getResources().getDrawable(R.drawable.ic_rounded_shape));


            counter++;
            tableRow.addView(button, 200, 250);


        }
        tableBoard.addView(tableRow, new TableLayout.LayoutParams(MP, WP));

    }

Image of my table

...