Reputation: 13302
I create a custom facebook login button, but the icon on the button is not showing corretly. can you help me please
Login XML:
<Button
android:id="@+id/login_button"
style="@style/ParseLoginUI.Button.ThirdPartyLogin"
android:layout_marginTop="@dimen/com_parse_ui_small_vertical_spacing"
android:background="@drawable/com_parse_ui_facebook_login_button_background_selector"
android:drawableLeft="@drawable/com_parse_ui_facebook_login_logo"
android:text="@string/com_parse_ui_facebook_login_button_label"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
Style:
<style name="ParseLoginUI.Button.ThirdPartyLogin" parent="ParseLoginUI.Button">
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">24dp</item>
</style>
<style name="ParseLoginUI.Button" parent="@android:style/Widget.Button">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">48dp</item>
<item name="android:background">@drawable/com_parse_ui_parse_login_button_background_selector</item>
<item name="android:textColor">@color/com_parse_ui_parse_login_display_text</item>
<item name="android:textSize">18sp</item>
</style>
Code:
loginButton = (Button)findViewById(R.id.login_button);
//loginButton.setBackgroundResource(R.drawable.com_parse_ui_facebook_login_logo); //DONT WORK
//loginButton.setCompoundDrawablesWithIntrinsicBounds(0, 0,0,0); //DONT WORK
I want my button to look like this https://i.sstatic.net/xKxX3.png originally its from the Parse sample
Upvotes: 0
Views: 2444
Reputation: 5732
Using facebook-android-sdk:3.19.0
dependency:
<com.facebook.widget.LoginButton
android:id="@+id/button_facebook_login"
android:drawableStart="@drawable/com_facebook_inverse_icon"
android:drawableLeft="@drawable/com_facebook_inverse_icon"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
If you are using facebook-android-sdk:4.20.0
, the drawable icon is named com_facebook_button_login_logo
Upvotes: 0
Reputation: 75788
No need to create extra drawable . Just call
<com.facebook.widget.LoginButton
android:id="@+id/authButtonFb"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
You will also need to add this to the Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fb="http://schemas.android.com/apk/res-auto"
For Details Login with Facebook And customize-android-facebook-login-button
If you use Android studio Then call this in your build.gradle
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
I hope it will helps you .
Upvotes: 1
Reputation: 13
instead of button use default facebook button(Please add facebook jar).it will give you same output as you want.
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />
Upvotes: 0