63

I already tried several answers I could find but none of them worked with the latest Facebook Android SDK version 4.0.

How can I change the layout height with the latest SDK?

Steffen
  • 2,197
  • 2
  • 24
  • 38

3 Answers3

179

Just set paddingTop and paddingBottom. It works for me.

<com.facebook.login.widget.LoginButton
        android:id="@+id/login_facebook_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="15dp"
        android:paddingBottom="15dp"
        android:layout_marginRight="30dp"
        android:layout_marginLeft="30dp"/>
Tiago Martins
  • 1,976
  • 1
  • 12
  • 8
  • 13
    How can we increase the size of the Facebook icon in the button? – Shajeel Afzal Feb 03 '16 at 22:15
  • 3
    I don't know why but when I set android:padding="16dp" it didn't work, only when I set each padding direction explicitly , thanks for the tip – Guy S Mar 23 '17 at 06:34
30

For Facebook SDK v4.x (or rather than using separate xml style or programmatically)

The height of button is decided by its padding and textSize.

So if you want to increase button size, do it something like this

<com.facebook.login.widget.LoginButton
xmlns:facebook="http://schemas.android.com/apk/res-auto"
facebook:com_facebook_login_text="Log in with Facebook"
android:id="@+id/login_button"
android:textSize="15sp"
android:paddingTop="15dp" <!--increase more until it matches ur requirement -->
android:paddingBottom="15dp">

Hope it helps!!

Rafique Mohammed
  • 3,666
  • 2
  • 38
  • 43
  • 10
    The material design guidelines recommend using an 8dp rhythm. Also, `sp` should be used only for text sizes, not dimensions. Finally, `` comments cannot be enclosed inside an XML tag. – Paul Lammertsma Jan 21 '17 at 12:58
  • @PaulLammertsma ofcz we can't put comment tag in properties. The is for explanation purpose not the actual code. – Rafique Mohammed Jan 15 '19 at 08:33
1

There is no need to create a custom LoginButton.

You can just change the LoginButton parameters programmatically as described here.

Community
  • 1
  • 1
Steffen
  • 2,197
  • 2
  • 24
  • 38