0

I want to have four button under action bar like this. But the problem is I can not remove the space between the buttons. I used negative margin but it does not look like this. So my question is how can I achieve this design? desired design

I did so far

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Sports"
        android:id="@+id/sports"
        android:layout_marginRight="-8dp"/>
    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Political"
        android:id="@+id/political"
        android:layout_toRightOf="@+id/sports"/>

and the output is enter image description here

Nadim Iqbal
  • 103
  • 2
  • 14
  • Your actual output is extremely small, and it looks like there is no gap between them (only button bevel). Please add a bigger image of what you are getting now, and clarify whether you are trying to remove a gap, ore create a flat button (no bevel) – Zerp Mar 25 '15 at 17:34

3 Answers3

3

You need to add to buttons borderless style.

style="?android:attr/borderlessButtonStyle"

It is a default system style, that using in themes, to create button bars.

Without it, always will be a small margin. You can read about it here, and here, from official documentation. It allows you to create button bars, like in your screenshot.

Community
  • 1
  • 1
VadymVL
  • 5,366
  • 3
  • 26
  • 41
0

Try this : Put all your buttons within Horizontal linear layout and set the width and height as follows,

    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.25"
Heshan Sandeepa
  • 3,388
  • 2
  • 35
  • 45
0

You can use linear layout for view button in same line. Using layout_weight