Android Google登录按钮和Facebook sdk 4+按钮布局 [英] Android Google Login Button and Facebook sdk 4+ Button Layout

查看:334
本文介绍了Android Google登录按钮和Facebook sdk 4+按钮布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 Google 和< a href =https://developers.facebook.com/ =noreferrer> Facebook 集成...我想修复那些按钮的高度和宽度...我想设置Button文本

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...

我已经尝试过了

<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" 

但是我收到错误:: =>找不到属性login_text在包中的资源标识符'com.test.b2c'

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

或通过编码

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

现在我的布局看起来像这样

Now My layout Look Something Like This

我也想设置这个按钮的高度和宽度.. ...
帮助我的朋友..... thx提前

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

更新

我在设置宽度方面没有直接的问题,我真正关心的是图片中显示的HEIGHT不一致。我需要找到更好的方法来使这些按钮的高度相等,并将文本设置为那些按钮。

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.

推荐答案

如果我们要更改Facebook的自定义文本登录..

If we wanna change custom text of Facebook Login ..

转到该图书馆的图书馆项目并转到string.xml

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

你会发现像这个

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

将此替换为您的自定义文本

Replace this with your custom text

尽管如果您想更改Google Plus的自定义文本,您可以

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

OnCreate 调用此

 setGooglePlusButtonText(signinButton,"your custom text");

// Google Plus的文字更改方法

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

对于Facebook的高度不一致添加填充到 Facebook按钮XML

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

android:paddingTop="20dp"
android:paddingBottom="20dp"

这篇关于Android Google登录按钮和Facebook sdk 4+按钮布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆