谷歌Android登录按钮和Facebook SDK 4+按钮布局 [英] Android Google Login Button and Facebook sdk 4+ Button Layout
问题描述
我是开发使用谷歌和应用< A HREF =https://developers.facebook.com/相对=nofollow> Facebook的融合......我要解决这些按钮的高度和宽度...我想设置按钮文本Manualy ...
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"/>
虽然我有attemted这样的事情
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
更新
我的设置没有直接的问题宽度什么是我真正关心的是图中所示不一致的高度。我需要找到更好的方式(S),使这些按钮的高度同样ND设置文本的按钮。
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 ..
进入到Facebook的库项目并转到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
但如果你想改变谷歌的自定义文本再加上你可以
Although if you want to change custom text of Google Plus you can
在的OnCreate 调用这个
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;
}
}
}
有关Facebook的高度inconsistancy我不得不添加填充为就可以建立XML
For Height inconsistancy of facebook i had add padding to Facebook Button XML
android:paddingTop="20dp"
android:paddingBottom="20dp"
这篇关于谷歌Android登录按钮和Facebook SDK 4+按钮布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!