Android谷歌登录按钮和Facebook sdk 4+按钮布局

Tuf*_*fan 13 android facebook android-linearlayout google-plus android-facebook

我正在开发一个使用谷歌Facebook集成的应用程序...我想修复那些按钮的高度和宽度...我想设置按钮文字手动...

我到目前为止尝试过

<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"/>
Run Code Online (Sandbox Code Playgroud)

虽然我已经注意到了这样的事情

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

         or 

    facebook:login_text="Login" 
Run Code Online (Sandbox Code Playgroud)

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

或通过编码

    loginButton = (LoginButton) findViewById(R.id.connectWithFbButton);
     loginButton.setText("Login");
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述

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

UPDATE

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

在此输入图像描述

Tuf*_*fan 12

如果我们想改变Facebook登录的自定义文本..

转到Facebook库项目并转到string.xml

你会发现这样的东西

  <string name="com_facebook_loginview_log_in_button_long">Log in with facebook </string>
Run Code Online (Sandbox Code Playgroud)

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

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

OnCreate打电话给这个

 setGooglePlusButtonText(signinButton,"your custom text");
Run Code Online (Sandbox Code Playgroud)

// 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;
         }
      }
}
Run Code Online (Sandbox Code Playgroud)

对于Facebook的高度不一致我已经添加填充到Facebook Button XML

android:paddingTop="20dp"
android:paddingBottom="20dp"
Run Code Online (Sandbox Code Playgroud)


kya*_*sar 11

这个样式的xml代码可以自定义我的应用程序的Facebook登录按钮,如图所示(文本和按钮大小).

<com.facebook.login.widget.LoginButton
    android:id="@+id/login_button"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="40dip"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"
    android:textSize="20sp"
    facebook:com_facebook_login_text="Facebook"
    facebook:com_facebook_logout_text="Facebook" />
Run Code Online (Sandbox Code Playgroud)

结果: 在此输入图像描述