Android - la Suppression de l'espace entre les Lignes TableLayout

0

La question

Je veux supprimer entre le Bouton "0" et le Bouton "1". Mon but c'est d'avoir le même espace entre eux, comme le Bouton "X". Résultat de l'INTERFACE utilisateur

Ces solutions n'ont pas fonctionné:

Comment faire pour supprimer l'espace entre deux lignes dans Tablelayout?

Comment réduire l'espace entre les deux rangées de Disposition de Table pour android?

Aussi, le Bouton "X" devrait s'étendre sur deux lignes, dont il ne, lorsque je l'ai mis dans un plus grand 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>

Merci d'avance pour toutes vos idées.

2

La meilleure réponse

0

J'ai essayé votre approche avec les imbriquée TableLayout et n'a pas pu supprimer l'espace complètement. Propriétés du bouton insetTop et insetBottom supprimé de l'espace de bien. Vous pouvez utiliser une approche différente en utilisant moins imbriqués les mises en page:

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

Merci beaucoup. Avec insetBottom et insetTop j'ai finalement obtenu. :)
sagalo1
0

C'est comment vous pouvez le faire

<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

Dans d'autres langues

Cette page est dans d'autres langues

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