Android - Rimozione di spazio tra TableLayout Righe

0

Domanda

Voglio rimuovere tra i pulsanti "0" e il Tasto "1". Il mio obiettivo è di avere lo stesso spazio tra di loro, come il Pulsante "X". UI risultato

Queste soluzioni non funzionano:

Come rimuovere lo spazio tra due righe in Tablelayout?

Come ridurre lo spazio tra le due righe della Tabella di Layout per android?

Inoltre, il Pulsante "X" dovrebbe spanna sopra le righe, che non solo, quando ho messo in una grande textSize.

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TableRow>
        
        <TableLayout android:layout_width="0sp"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <TableRow android:layout_width="0sp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_margin="0sp"
                android:padding="0sp">
                <com.google.android.material.button.MaterialButton
                    android:layout_width="0sp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="0"
                    android:layout_margin="2sp"
                    />
            </TableRow>
            
            <TableRow
                android:layout_width="0sp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:layout_margin="0sp"
                android:padding="0sp">
                <com.google.android.material.button.MaterialButton
                    android:layout_width="0sp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="1"
                    android:layout_margin="2sp"
                    />
            </TableRow>
        </TableLayout>
        
        <TableLayout
            android:layout_width="0sp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:layout_margin="0sp"
            android:padding="0sp">
            <TableRow>
                <com.google.android.material.button.MaterialButton
                    android:layout_width="0sp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:text="X"
                    android:layout_margin="2sp"
                    />
            </TableRow>
        </TableLayout>
        
    </TableRow>
</TableLayout>

Grazie in anticipo per tutte le idee.

2

Migliore risposta

0

Ho provato il tuo approccio con il nidificati TableLayout e non è riuscito a togliere spazio completamente. Pulsante proprietà insetTop e insetBottom rimosso un po ' di spazio anche se. È possibile utilizzare un approccio diverso, utilizzando meno nidificati layout:

Table layout without a space

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:insetBottom="0dp"
            android:text="1" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:insetBottom="0dp"
            android:text="X" />
    </TableRow>

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

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:insetTop="0dp"
            android:text="Button" />

        <Space
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5" />
    </TableRow>
</TableLayout>
2021-11-17 07:19:28

Grazie mille. Con insetBottom e insetTop ho finalmente capito. :)
sagalo1
0

Questo è come si può fare

<TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    <TableRow>

        <TableLayout
                android:layout_width="0sp"
                android:layout_height="match_parent"
                android:layout_weight="1">

            <TableRow
                    android:layout_width="0sp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:padding="0sp">

                <com.google.android.material.button.MaterialButton
                        android:layout_width="0sp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="0" />
            </TableRow>

            <TableRow
                    android:layout_width="0sp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:padding="0sp">

                <com.google.android.material.button.MaterialButton
                        android:layout_width="0sp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="1" />
            </TableRow>
        </TableLayout>
        
        <com.google.android.material.button.MaterialButton
                android:layout_width="0sp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="X" />

    </TableRow>
</TableLayout>
2021-11-17 07:09:58

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................