Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android Google plus login customization

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

like image 473
Cafn Avatar asked Jul 13 '14 03:07

Cafn


People also ask

How do I customize my Google login button?

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 .

What is ASL Google signin button?

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.

Is login with Google free?

Google Sign-in is a free service.


2 Answers

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;
        }
    }
}
like image 117
Jitender Chaudhary Avatar answered Sep 28 '22 16:09

Jitender Chaudhary


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.

like image 37
swooby Avatar answered Sep 28 '22 15:09

swooby