The new Facebook SDK for Android (v4.0) that was released recently caused strange behavior for a customized LoginButton I'm using. Below is a comparison of how the same XML is rendered in different SDK versions.
The problem seems to be that the FB icon in SDK 4.x doesn't stretch properly to fit a custom-sized button, and at 4.0.1 the android:layout_height
property is ignored altogether.
My question is how do I make the button appear in SDK 4.x like it did in SDK 3.x? Both XML and Java solutions are perfectly acceptable.
XML for SDK 3.x:
<com.facebook.widget.LoginButton
android:background="@color/com_facebook_blue"
android:id="@+id/login_btn_facebook"
android:layout_width="225dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_gravity="center"
android:onClick="onFacebookLoginClick"
/>
How it looks on SDK 3.x (screenshot taken on a OnePlus One, running CM11S):
XML for SDK 4.x (the button's package was renamed + I had to change the width & font a bit to match the g+ button):
<com.facebook.login.widget.LoginButton
android:background="@color/com_facebook_blue"
android:id="@+id/login_btn_facebook"
android:layout_width="221dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_gravity="center"
android:textSize="7pt"
android:onClick="onFacebookLoginClick"
/>
How it looks on SDK 4.0 (Screenshot taken on a Genymotion Nexus 5, running unmodified 4.4.4):
How it looks on SDK 4.0.1 (Same Genymotion Nexus 5):
Additional information
- Excerpt from the 4.0 -> 4.0.1 SDK change log:
Login button is updated to properly measure its size.
Related posts:
To support different screen sizes, above the login buttons I have a ViewPagerIndicator and a ViewPager that is configured to take up all available vertical space which remains after positioning elements with defined height.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…