3

Использую этот код, и получается такая картинка:

введите сюда описание изображения

private void GrdidGenerate() {
    for (int i = 0; i < LevelGrid[pos]; i++) {
        TableRow tableRow = new TableRow(this);
        tableRow.setLayoutParams(new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
        for (int j = 0; j < LevelGrid[pos]; j++) {
            ImageView imageView = new ImageView(this);
            TableRow.LayoutParams params = new TableRow.LayoutParams(100 / LevelGrid[pos],
                    100 / LevelGrid[pos], 1);
            params.setMargins(5, 5, 5, 5);
            imageView.setLayoutParams(params);
            imageView.setImageResource(R.drawable.abc_btn_radio_material);
            imageView.setBackgroundColor(Color.rgb(r, g, b));
            imageView.setAdjustViewBounds(true);
            tableRow.addView(imageView, j);
        }
        grid.addView(tableRow, i);
    }
}

Как сделать так, чтобы колонки растягивались на всю длину и не вылезали за поля?

1 ответ 1

2

Решил проблему, так:

TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT, 1);
2
  • Отметьте ваш ответ, как верный (нажмите на серую галку слева от сообщения)
    – pavlofff
    11 июл 2015 в 3:27
  • @pavlofff , через пять часов только смогу)
    – alex11
    11 июл 2015 в 7:24

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.