I'm creating a Android application and right now i'm implementing the social networks login.
Facebook button is fine, but the google+ button is in a different language of the facebook one. Also, it only says "sign in", and i would like to have it to say "sign in with google"
I'm new to the android programation, and saw that i need to make a custom button, but dont know how to do it(where to start it, how to call it) and make it look like google plus one.
Could anyone give me a little bit of help?
Thanks
I found two ways:
1) Fight it with a custom button:
<Button
android:id="@+id/btnGooglePlus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/common_signin_btn_text_dark"
android:text="@string/common_signin_button_text_long"
android:textColor="@android:color/white"
android:textAllCaps="false"
android:textSize="15sp"
android:paddingEnd="16dp"
android:paddingStart="62dp"/>
2) Don't fight it (too much):
<com.google.android.gms.common.SignInButton
android:id="@+id/btnGooglePlus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
mGooglePlusSignInButton = (SignInButton) findViewById(R.id.btnGooglePlus);
mGooglePlusSignInButton.setSize(SignInButton.SIZE_WIDE);
setGooglePlusTextAllCaps(mGooglePlusSignInButton, false);
public static void setGooglePlusTextAllCaps(SignInButton signInButton, boolean allCaps)
{
for (int i = 0; i < signInButton.getChildCount(); i++)
{
View v = signInButton.getChildAt(i);
if (v instanceof TextView)
{
TextView tv = (TextView) v;
tv.setAllCaps(allCaps);
return;
}
}
}
The main trick seems to be the "mGooglePlusSignInButton.setSize(SignInButton.SIZE_WIDE);" method.
Try this function to change google plus button text.
protected void setGooglePlusButtonText(SignInButton signInButton,
String buttonText) {
for (int i = 0; i < signInButton.getChildCount(); i++) {
View v = signInButton.getChildAt(i);
if (v instanceof TextView) {
TextView tv = (TextView) v;
tv.setTextSize(15);
tv.setTypeface(null, Typeface.NORMAL);
tv.setText(buttonText);
return;
}
}
}
Set app:buttonSize="wide"
like this
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
app:buttonSize="wide"
android:layout_alignParentBottom="true"
android:layout_marginBottom="48dp"/>
But, don't forget to add this xml namespace prefix in the top
xmlns:app="http://schemas.android.com/apk/res-auto"
Per the Customizing your Google+ sign in button guide, you can use
android:text="@string/common_signin_button_text_long"
to get the text 'Sign in with Google' on your sign in button as discussed in the Google+ sign in branding guidelines