Android - Odstranění mezery mezi TableLayout Řádky

0

Otázka

Chci odstranit mezi Tlačítko "0" a Tlačítko "1". Mým cílem je mít stejný prostor, mezi nimi i Tlačítko "X". UI výsledek

Tato řešení nefunguje:

Jak odstranit prostor mezi dvěma řádky, v Tablelayout?

Jak snížit prostor mezi dvěma řádky Tabulky Rozložení pro android?

Také, Tlačítko "X" by se klenou přes oba řádky, které to dělá jen, když jsem dal větší 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>

Díky předem za nějaké nápady.

2

Nejlepší odpověď

0

Snažil jsem se svůj přístup s vnořené TableLayout a nepodařilo se odstranit prostor zcela. Tlačítko vlastnosti insetTop a insetBottom odstraněny některé prostor. Můžete použít jiný přístup s využitím méně vnořené rozvržení:

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

Díky moc. S insetBottom a insetTop jsem se konečně dostal to. :)
sagalo1
0

To je, jak můžete udělat to

<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

V jiných jazycích

Tato stránka je v jiných jazycích

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