Android 23 and under do not fill all screens in landscape mode

2

I make an application that uses dynamic tables, my XML code is:

<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"
             android:stretchColumns="*">

        </TableLayout>
    </ScrollView>
</HorizontalScrollView>

The table takes all Java code values:

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 ...

My problem is that in versions of Android 23 and below, when you put the orientation of the screen in landscape mode, the screen looks like this:

But in Android versions 24 and older, it looks good:

P.D: Property match_parent does not work.

    
asked by Gonzalo León 13.06.2017 в 18:23
source

1 answer

2

Finally, after 1 week searching and reading I found the solution to my problem. Use CoordinatorLayout and NestedScrollView

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<include
    android:id="@id/action_bar"
    layout="@layout/actionbar_toolbar" />

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TableLayout
            android:id="@+id/table"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:stretchColumns="*" />
    </HorizontalScrollView>

</android.support.v4.widget.NestedScrollView>

    
answered by 13.06.2017 в 22:14