4

I am trying to achieve the look of Facebook's event page and am having trouble copying their three buttons that say if a person is going to an event.

I am trying to achieve this,

enter image description here

Mine currently looks like this,

enter image description here

This is the XML for the buttons

    <LinearLayout
        android:id="@+id/button_holder"
        android:layout_alignParentBottom="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="3"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:paddingBottom="10dp">

        <Button
            android:id="@+id/button_going"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="14sp"
            android:textColor="@color/secondary_text"
            android:text="Going"
            android:background="@drawable/item_left_button_background"/>

        <Button
            android:id="@+id/button_maybe"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="14sp"
            android:textColor="@color/secondary_text"
            android:text="Maybe"
            android:background="@drawable/item_middle_button_background"/>

        <Button
            android:id="@+id/button_decline"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="14sp"
            android:textColor="@color/secondary_text"
            android:text="Decline"
            android:background="@drawable/item_right_button_background"/>

    </LinearLayout>

I do not know where the extra Padding or Margin is coming from above and below my buttons. I have tried android:padding="0dp" and android:layout_margin="0dp" on the buttons but it had no effect.

My best guess is it might have something to do with the layout_weight attribute. This may give the buttons a certain height based on their width, if this is the case then how can I make the buttons shorter?

Gary Holiday
  • 3,297
  • 3
  • 31
  • 72

1 Answers1

3

AS you are applying the background item_left_button_background so that must be an image or selector which consists images those images have a specific height. When you give the button height as wrap_content it will take by default what is height of the image so as per my suggestion give a specific height to the button or create the background images as per your required sizes

Vishwajit Palankar
  • 3,033
  • 3
  • 28
  • 48
  • 1
    This worked well. I didn't think about the fact that the background's had a set height, since they are a ``. For anyone that may want to achieve this I went with `height="35dp"` to achieve the Facebook look. – Gary Holiday May 12 '15 at 05:36
  • thats great, if my answer helped you can accept it though :) – Vishwajit Palankar May 12 '15 at 05:37