布局Google登录按钮-Android [英] Layout Google Sign In Button - Android
问题描述
我到处搜索,没有找到想要的东西,我开始认为这是不可能的.
I'm searching everywhere and not finding what I want, I'm starting to think that this is impossible.
这里是问题:我有一个用于登录的google按钮,这是一个漂亮的按钮,但它不适合我的布局,我想使用由我在google按钮中创建的图像,例如发生的情况在图像按钮中,这可能吗?如果是,该怎么办?
Here's the question: I have a google button for sign in, it's a beautiful button, but it doesn't fit in my layout, I would like to use an image, created by me in the google button, like what happens in the Image Buttons, is that possible? If yes, how can I do this?
谢谢
推荐答案
我有您的问题解决方案.我总是尝试将其用于Google Plus的自定义登录按钮.
I have your question solution. I tried this always for custom SignIn Button for google plus.
尝试一下,这是我测试过的.
Try this it is tested by me.
这是代码.
xml布局
<com.google.android.gms.common.SignInButton
android:id="@+id/google_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:text="Text"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:textSize="18sp" />
自定义方法
private void googleBtnUi() {
// TODO Auto-generated method stub
SignInButton googleButton = (SignInButton) findViewById(R.id.google_button);
googleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
for (int i = 0; i < googleButton.getChildCount(); i++) {
View v = googleButton.getChildAt(i);
if (v instanceof TextView)
{
TextView tv = (TextView) v;
tv.setTextSize(14);
tv.setTypeface(null, Typeface.NORMAL);
tv.setText("My Text");
tv.setTextColor(Color.parseColor("#FFFFFF"));
tv.setBackgroundDrawable(getResources().getDrawable(
R.drawable.ic_launcher));
tv.setSingleLine(true);
tv.setPadding(15, 15, 15, 15);
return;
}
}
}
编辑
在方法googleBtnUi()
ViewGroup.LayoutParams params = tv.getLayoutParams();
params.width = 100;
params.height = 70;
tv.setLayoutParams(params);
这篇关于布局Google登录按钮-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!