J'utilise un TableLayout sur mon application. Ceci est mon code XML:Comment remplir tout l'écran avec un tablelayout en mode paysage?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scrollbars="none">
<include
android:id="@id/action_bar"
layout="@layout/actionbar_toolbar" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/action_bar">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TableLayout
android:id="@+id/table"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
</HorizontalScrollView>
Et, je remplir le tableau avec le code Java:
TableRow tbrow = new TableRow(this);
TextView txt_plazo = new TextView(this);
txt_plazo.setText(" Plazo ");
txt_plazo.setTextColor(Color.WHITE);
txt_plazo.setTextSize(16);
txt_plazo.setMinimumHeight(0);
txt_plazo.setBackgroundColor(Color.DKGRAY);
txt_plazo.setGravity(Gravity.CENTER);
tbrow.addView(txt_plazo);
TextView txt_saldoInicial = new TextView(this);
txt_saldoInicial.setText(" Saldo Inicial");
txt_saldoInicial.setTextColor(Color.WHITE);
txt_saldoInicial.setTextSize(16);
txt_saldoInicial.setBackgroundColor(Color.DKGRAY);
txt_saldoInicial.setGravity(Gravity.CENTER);
tbrow.addView(txt_saldoInicial);
TextView txt_parcialidades = new TextView(this);
txt_parcialidades.setText(" Parcialidades ");
txt_parcialidades.setTextColor(Color.WHITE);
txt_parcialidades.setTextSize(16);
txt_parcialidades.setBackgroundColor(Color.DKGRAY);
txt_parcialidades.setGravity(Gravity.CENTER);
tbrow.addView(txt_parcialidades);
TextView txt_interes = new TextView(this);
txt_interes.setText(" Interés ");
txt_interes.setTextSize(16);
txt_interes.setBackgroundColor(Color.DKGRAY);
txt_interes.setGravity(Gravity.CENTER);
txt_interes.setTextColor(Color.WHITE);
tbrow.addView(txt_interes);
TextView txt_total = new TextView(this);
txt_total.setText(" Abono Capital");
txt_total.setTextSize(16);
txt_total.setBackgroundColor(Color.DKGRAY);
txt_total.setGravity(Gravity.CENTER);
txt_total.setTextColor(Color.WHITE);
tbrow.addView(txt_total);
table.addView(tbrow);
fillTable();
Etc ...
Tout fonctionne très bien, mais je suis en train pour voir la table en mode paysage, le problème est que la table ne remplit pas tout l'écran. En mode portrait a l'air bien.
P.D: android:shrinkColumns
et android:stretchColumns
ne fonctionnent pas pour moi.
Utiliser 'fill_parent' au lieu de' 'wrap_content' pour layout_width' de votre point de vue – bartolja
ensemble android: layout_width = "match_parent" à tous les trois vues HorizontalScrollView, ScrollView, TableLayout. – mdb
Les deux méthodes ne fonctionnent pas –