0

I have 8 buttons inside a LinearLayout and I don't want any space betwen them. I have tried set all padding and margins to 0 and nothing.

Any solutions?

jbihan
  • 3,053
  • 2
  • 24
  • 34
  • Did you use weight? They should be right on top of each other if you didn't use weight. Else try using negative margins. – Ben Kane Oct 09 '13 at 20:12
  • Try using google chrome inspect or web developer toolbar on firefox to check if there are any overriding styling rules. Also try making the styling rules important ie .button {padding:0 !important; margin:0 !important;} – The Humble Rat Oct 09 '13 at 20:17
  • 3
    Please post the layout XML (or code, if you're generating the layout procedurally). If you could post an image of what you're seeing and an image of what you want, those would help as well. – Ted Hopp Oct 09 '13 at 20:21
  • this appears to have worked for other users http://stackoverflow.com/questions/4361309/remove-space-between-buttons – MadWayne Oct 09 '13 at 20:49

2 Answers2

0

You could use negative margins but could be bad practice. Most 9-patch PNGs have transparent areas around the visible ones, that could be why it looks like you have margins. Try turning-on Show layout boundaries to investigate. It's under Settings > Developer Options.

Community
  • 1
  • 1
user1923613
  • 626
  • 5
  • 11
  • 31
0

Try this code. Use layout_weight=1 while, layout_width="0dp".

<LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:padding="3dp"
    android:background="@color/green">

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/green"
        android:text="Submit"
        android:textColor="@color/white"
        android:layout_weight="1"
        android:id="@+id/submitQuestionnaireButton"/>
    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:text="Cancel"
        android:textColor="@color/green"
        android:layout_weight="1"
        android:id="@+id/cancelQuestionnaireButton"/>
</LinearLayout>
Fahry Mohammed
  • 599
  • 5
  • 18