Witam, mam problem z tabelkami w Androidzie. Szukałem po tutorialach ale nie znalazłem niczego co pomogłoby mi rozwiazac problem. Mianowicie mam tabelke, ktora moge scrollowac ale jest problem z zamieszczeniem calej na ekranie. Mam 4 naglowki ale z racji ze zawartosc kolumn nieraz jest dluga to rozszerza mi je przez co w orientacji pionowej widac tylko 2 a poziomej 3 kolumny. Moglby ktos poratowac?
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TableLayout
android:id="@+id/table"
android:layout_height="match_parent"
android:layout_width="wrap_content">
</TableLayout>
</ScrollView>
TableLayout table = (TableLayout) findViewById(R.id.table);
table.removeAllViewsInLayout();
TableRow headerRow = new TableRow(getApplicationContext());
ArrayList<String> headers = new ArrayList<>();
headers.add("h1");
headers.add("h2");
headers.add("h3");
headers.add("h4");
for(int i = 0; i < headers.size(); i++) {
TextView header = new TextView(getApplicationContext());
header.setText(headers.get(i));
header.setTextColor(Color.WHITE);
header.setBackgroundColor(Color.rgb(24, 116, 205));
header.setPadding(15, 15, 15, 15);
header.setTextSize(20);
headerRow.addView(header);
}
table.addView(headerRow);
for (int i = 0; i < tlmJsonParserObj.getRecords().size(); i++) {
Map<String, String> row = tlmJsonParserObj.getRecords().get(i);
TableRow tr = new TableRow(getApplicationContext());
String bgColor = "silver";
if(i % 2 == 0) bgColor = "white";
tr.setBackgroundColor(Color.parseColor(bgColor));
ArrayList<String> cells = new ArrayList<>();
cells.add(row.get("c1"));
cells.add(row.get("c2"));
cells.add(row.get("c3"));
cells.add(row.get("c4"));
for(int k = 0; k < cells.size(); k++) {
TextView cell = new TextView(getApplicationContext());
cell.setText(cells.get(k));
cell.setTextColor(Color.BLACK);
//cell.setBackgroundColor(Color.rgb(24, 116, 205));
//cell.setPadding(10, 10, 10, 10);
cell.setTextSize(15);
tr.addView(cell);
}
table.addView(tr);
Wygląda to tak:
https://s3.amazonaws.com/aww-imagedata/81d03998-55af-4056-bdb0-0f9b8a21fe2e.png
A ja chcę, żeby w każdej orientacji wyświetlały się wszystkie kolumny i w razie czego łamało mi linie w kolejnych wierszach.
Pozdrawiam