Center TextView Programmgesteuert auf Tabellenzeilen
Ich versuche, mich zu zentrieren, eine textview innerhalb einer Tabellenzeilen, ist, dass sich im inneren ein tablelayout, aber ich glaube, ich bin etwas fehlt, weil die TextView nicht zentriert zu bekommen :s
Hier ist meine Methode:
private void insertClock() {
TableLayout table = new TableLayout(this);
table.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
table.setStretchAllColumns(true);
TableRow tbRow = new TableRow(this);
TableLayout.LayoutParams layoutRow = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
clock = new TextView(this);
TableRow.LayoutParams layoutHistory = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
clock.setLayoutParams(layoutHistory);
clock.setText(calculateClockText());
tbRow.setLayoutParams(layoutRow);
table.addView(tbRow);
clock.setGravity(Gravity.CENTER_HORIZONTAL);
tbRow.addView(clock);
}
Vielen Dank im Voraus 😉
Du musst angemeldet sein, um einen Kommentar abzugeben.
Finnaly gemacht, es funktioniert !
Hier ist die Lösung: