Search code examples
androidfacebookbuttonandroid-linearlayoutgoogle-signin

Social (Google & Facebook) buttons don't align in a horizontal LinearLayout


So as the title says; I am having issues with aligning my social login buttons within a horizontal LinearLayout. I have tried this with normal buttons and they align perfectly, but whenever I switch back to the Facebook and Google buttons they misalign for some reason.

This is what they look like in design view:

enter image description here

And this is my XML code:

    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <com.facebook.login.widget.LoginButton
                android:id="@+id/facebookButton"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_gravity="center_horizontal"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:layout_weight="1"
                android:layout_marginStart="16dp" />


            <com.google.android.gms.common.SignInButton
                android:id="@+id/googleButton"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:layout_marginEnd="13dp"/>


        </LinearLayout>

Solution

  • Try putting android:layout_gravity="center" in your LinearLayout.