Stephen
Stephen

Reputation: 10059

TableLayout: Buttons have to stick together without leaving any space

main.xml:

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

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="0dip"
                android:layout_weight="5" >
            </FrameLayout>

              <TableLayout 
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical" 
                  >

                  <TableRow
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal" >

                      <Button
                          android:id="@+id/button1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="BOOKS" />

                      <Button
                          android:id="@+id/button2"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="LIBRARY" />

                      <Button
                          android:id="@+id/button3"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="MATH" />

                      <Button
                          android:id="@+id/button4"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="MUSEUM" />

                      <Button
                          android:id="@+id/button5"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="+24" />
                  </TableRow>

                 </TableLayout>


            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0" />
        </LinearLayout>
    </TabHost>

</LinearLayout>

My problem is Buttons have to stick together without leaving any space.Anybody can help me with these.Thank you.

Upvotes: 0

Views: 155

Answers (1)

Pragnesh Ghoda  シ
Pragnesh Ghoda シ

Reputation: 8337

There is Tricky Solution For it...

You Just Have to Set Negative Margins For it....
Just set the android:layout_marginRight of the first button to "-7dip" or even more.

Try Code Something like below... Set Margins As Your Need

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="-7dip"
                android:text="BOOKS" />

            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="-7dip"
                android:text="LIBRARY" />

            <Button
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="-7dip"
                android:text="MATH" />

            <Button
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="-7dip"
                android:text="MUSEUM" />

            <Button
                android:id="@+id/button5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="-7dip"
                android:text="+24" />
        </TableRow>
    </TableLayout>

Upvotes: 1

Related Questions