Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Google Login Button and Facebook sdk 4+ Button Layout

I Am developing an application which use google and facebook integration ...I want to fix height and width of those button...and i want to set Button Text Manualy...

i had tried so far

<com.facebook.login.widget.LoginButton
       xmlns:fb="http://schemas.android.com/apk/res-auto"
       android:id="@+id/connectWithFbButton"  
       android:layout_width="match_parent"
       android:layout_height="50dp"
       android:layout_marginLeft="10dp"
       android:layout_marginRight="10dp"
       android:text="@string/fbloginText"
       android:layout_marginTop="30dp"
/>

<com.google.android.gms.common.SignInButton
        android:id="@+id/signin"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="@string/googleloginText" 
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="20dp"/>

although i had attemted something like this

    fb:login_text="Login"
    fb:logout_text="Logout"

         or 

    facebook:login_text="Login" 

But i Got Error::=>No resource identifier found for attribute 'login_text' in package 'com.test.b2c'

or in by coding

    loginButton = (LoginButton) findViewById(R.id.connectWithFbButton);
     loginButton.setText("Login");

Now My layout Look Something Like This

enter image description here

I also want to set Height And width of this buttons .. ... help me friends .....thx in advance

UPDATE

I have no direct problem in setting width what am I really concern is the inconsistent HEIGHT shown in the picture. I need to find better way(s) to make those buttons height equally nd set Text to those Button.

enter image description here

like image 266
Tufan Avatar asked May 21 '15 06:05

Tufan


People also ask

How to add Facebook login using Facebook SDK in Android Studio?

So here is the complete step by step tutorial for Android Studio Add Facebook Login using Facebook SDK 4 Tutorial. 1. Create a fresh project in Android Studio. 2. After done creating project open developers.facebook.com . 3. Login with your Facebook ID. 4. After successfully login Click on Create App button. 5.

How to build a Facebook login app using Kotlin/Java?

Give the name of your app like “Facebook Login UI”. Then select Kotlin/Java as the programming language. Then select minimum SDK for example in this we are using “API16: Android 4.1 (Jelly Bean)”. then click on the finish button.

How do I add Facebook authentication to an Android app?

You can add Facebook authentication to an Android app, using the LoginButton that’s conveniently included in the Facebook SDK. LoginButton is a custom view implementation of Button, which wraps functionality available in the LoginManager.

How do I use the Facebook SDK with Facebook Analytics?

When you use the Facebook SDK, certain app events and actions are automatically recorded by Facebook Analytics, unless you explicitly disable event logging. By default, all of the following events and actions will be logged, and then displayed in your app’s Insights dashboard: App Installs.


1 Answers

If we wanna change custom text of Facebook Login ..

Go to that Facebook library project And go to string.xml

you will find something like this

  <string name="com_facebook_loginview_log_in_button_long">Log in with facebook </string>

Replace this with your custom text

Although if you want to change custom text of Google Plus you can

From OnCreate call this

 setGooglePlusButtonText(signinButton,"your custom text");

//Text Change Method Of Google Plus

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;
         }
      }
}

For Height inconsistancy of facebook i had add padding to Facebook Button XML

android:paddingTop="20dp"
android:paddingBottom="20dp"
like image 94
Tufan Avatar answered Oct 07 '22 20:10

Tufan