How to fill the entire screen in "Landscape" Table Layout mode?

Asked

Viewed 135 times

0

I am using a "Tablelayout" in my application. This is my XML code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_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>

The table is dynamically filled with code:

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);

Etc. ...

Everything works fine, but I’m trying to see the table in "Landscape" mode, the problem is that the table does not fill the entire screen.

landscape

I’ve already tried: android: stretchColumns = "*", but it only works on small screens.

telas pequenas

I’ve tried everything, but nothing works. While just see the "Landscape" mode on small screens.

  • Try to put android:layout_width="math_parent" in HorizontalScrollView and ScrollView, and android:layout_weight="1" in the TabLayout.

  • Ya intenté usar "match_parent" es la Respuesta que Veo siempre, pero no funciona. Y android:layout_weight="1" no funciona no Tablelayout.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.