Wie kann ich mich dehnen und schrumpfen Spalten, wenn meine Tabellenzeilen dynamisch generiert wird?

Ich bin mit einem TableLayout und füllen es dynamisch mit einer angepassten Zeile, aber jetzt, wenn ich die Verwendung von android:stretchColumns android:shrinkColumns es funktioniert nicht.

Meine Aktivität layout:

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView 
        android:text="@string/offline"
        android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="20dp"
    android:textStyle="bold"
    android:textSize="20sp"
    android:textColor="@color/dimGray"
    />

    <TableLayout
    android:id="@+id/download_full_table"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="20dp"
    android:stretchColumns="2"
    android:shrinkColumns="1"
    >
</LinearLayout>

Meine Zeile layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

    <TableRow 
        android:background="@color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="*">

        <TextView

            android:id="@+id/row_name"
            android:text="@string/empty" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:textSize="12sp"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="7dp"
            android:layout_marginRight="10dp"
             />

        <TextView
            android:id="@+id/row_size"
            android:text="@string/empty" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/lightGray"
            android:layout_marginTop="7dp"
             />

        <Button 
            android:id="@+id/row_btnDownload"
            android:text="@string/baixar"
            android:layout_width="wrap_content" 
            android:layout_height="35dp"
            android:background="@drawable/btn_baixar_verde"
            android:textColor="@color/white"
            android:textSize="13sp"
            android:layout_marginTop="7dp"
            android:layout_marginBottom="7dp"
            android:layout_marginLeft="7dp"
            android:layout_marginRight="15dp"
            android:textStyle="bold"

            />

    </TableRow>

</LinearLayout>

Mein code:

TableLayout tableFullDownload = (TableLayout) findViewById(R.id.download_full_table);

LayoutInflater inflater = getLayoutInflater();

ArrayList<MetaDados> fullList = getIntent().getParcelableArrayListExtra("metaDadosFull");

for (MetaDados metaDados : fullList) {
    LinearLayout row = (LinearLayout) inflater.inflate(R.layout.download_table_row, tableFullDownload, false);
    TextView name = (TextView) row.findViewById(R.id.row_name);
    TextView size = (TextView) row.findViewById(R.id.row_size);

    name.setText(metaDados.getName());

    long fileSize = metaDados.getSize();
    fileSize = (fileSize / 1024) / 1024;
    String sizeToShow = (fileSize + " MB");

    size.setText(sizeToShow);

    tableFullDownload.addView(row);
}

Was ich habe:

Wie kann ich mich dehnen und schrumpfen Spalten, wenn meine Tabellenzeilen dynamisch generiert wird?

Was ich will:

Wie kann ich mich dehnen und schrumpfen Spalten, wenn meine Tabellenzeilen dynamisch generiert wird?

Schreibe einen Kommentar