0

enter image description hereenter image description hereI have this layout for my header:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
 android:orientation="horizontal"
>


 <Button android:id="@+id/home"
  android:layout_width="0dp" 
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:text="Home"
  android:background="@drawable/ic_menu"
  android:textSize="11dp"
/>

<Button android:id="@+id/questions"
 android:layout_width="0dp" 
 android:layout_height="wrap_content"
 android:layout_weight="1"
 android:text="Questions"
 android:textSize="11dp"
   android:background="@drawable/ic_menu"
android:layout_toRightOf="@+id/home"  />  


 <Button android:id="@+id/businesses"
  android:layout_width="0dp" 
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:textSize="11dp"
  android:text="Businesses"
    android:background="@drawable/ic_menu"
  android:layout_toRightOf="@+id/questions"
 />  

 <Button android:id="@+id/learn"
  android:layout_width="0dp" 
  android:layout_height="wrap_content"
  android:layout_weight="1"
  android:text="Learn"
  android:textSize="11dp"
  android:background="@drawable/ic_menu"
  android:layout_toRightOf="@+id/businesses"
 />  

</LinearLayout>

What I thought was that if I made the button backgrounds with images, then that would enable me to not have space between the buttons. Right now, the header buttons render nicely, but there is a thick whitespace background space between them. How could I get rid of that white space and make the space between them just 1px?

I just uploaded a photo of the emulator. See the 4 dark boxes on the top of the screen? That is the header with the spaces.

Thanks!

GeekedOut
  • 16,905
  • 37
  • 107
  • 185

2 Answers2

1

There is a potential solution in a similar question here, Is there a way to completely eliminate padding in a LinearLayout containing buttons?

Your drawable ic_menu could have padding, if you are using a 9-patch for that image, when you author it make sure the black lines along the right and bottom are as you intended, because this is for specifying the content area in your 9-patch and could contribute to padding.

Also, try adding 0dp for both margin and padding on the buttons.

Hope that helps.

Community
  • 1
  • 1
Ian Warwick
  • 4,774
  • 3
  • 27
  • 27
1

The problem is that the image contains a border color. Remove the border from the image, or use a solid color #868686, which is the image center color.

yoah
  • 7,180
  • 2
  • 30
  • 30