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
To create a Google Sign-In button with custom settings, add an element to contain the sign-in button to your sign-in page, write a function that calls signin2. render() with your style and scope settings, and include the https://apis.google.com/js/platform.js script with the query string onload=YOUR_RENDER_FUNCTION .
The @abacritt/angularx-social-login package comes with the <asl-google-signin-button></asl-google-signin-button> element, which displays the icon on screen. When clicked, this element initiates the Google Authentication.
Google Sign-in is a free service.
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;
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With