Christine
Christine

Reputation: 329

Issue with android buttons layout

I Guess something is wrong with the layout, earlier I had only three buttons, now I added one more button and now layout is behaving weird. Any idea? How can i have proper rendering of buttons and text in it

layout.xml

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_centerInParent="true"
    android:gravity="bottom"
     >

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#092435"
        android:gravity="center_horizontal" >

        <Button
            android:id="@+id/home"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:background="#092435"
            android:gravity="center"
            android:padding="15dip"
            android:text="AA"
            android:textColor="#ffffff" />

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_marginTop="6dip"
            android:layout_marginBottom="6dip"
            android:background="#85929B" />

        <Button
            android:id="@+id/status"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:background="#092435"
            android:gravity="center"
            android:padding="15dip"
            android:text="BB"
            android:textColor="#ffffff" />

         <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_marginTop="6dip"
            android:layout_marginBottom="6dip"
            android:background="#85929B"  />

        <Button
            android:id="@+id/support"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:background="#092435"
            android:gravity="center"
            android:padding="15dip"
            android:text="CC"
            android:textColor="#ffffff" />

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_marginTop="6dip"
            android:layout_marginBottom="6dip"
            android:background="#85929B"/>

        <Button
            android:id="@+id/survey"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:background="#092435"
            android:gravity="center"
            android:padding="15dip"
            android:text="DD"
            android:textColor="#ffffff" />
    </TableRow>
 </TableLayout>

Upvotes: 0

Views: 52

Answers (2)

ligi
ligi

Reputation: 39539

The problem is that when you added another button some got to 2 lines and this messes up your layout. Give them a fixed height and this should fix your problem.

also:

  • To debug things like this use "show layout bounds"
  • a table with only one row is not really useful

Upvotes: 1

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

Change padding parameter to the button's in the xml file

android:padding="15dip"

to

android:padding="2dip"

Upvotes: 1

Related Questions