Android - Quitar el espacio entre Filas TableLayout

0

Pregunta

Quiero eliminar entre el Botón "0" y el Botón "1". Mi objetivo es tener el mismo espacio entre ellos como el Botón "X". Interfaz de usuario resultado

Estas soluciones no funcionan:

Cómo quitar el espacio entre dos filas de Tablelayout?

Cómo reducir el espacio entre las dos filas de la Tabla de Diseño para android?

También, el Botón "X" debe lapso de más de dos filas, que sólo se hace, que cuando me pongo en una más 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>

Gracias de antemano por las ideas.

2

Mejor respuesta

0

Traté de que su acercamiento con la anidados TableLayout y no se ha podido eliminar el espacio completamente. Propiedades del botón insetTop y insetBottom quita un poco de espacio, aunque. Usted puede utilizar un enfoque diferente con menos anidada diseños:

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

Muchas gracias. Con insetBottom y insetTop por fin lo conseguí. :)
sagalo1
0

Esto es cómo usted puede hacerlo

<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

En otros idiomas

Esta página está en otros idiomas

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