如何使默认的Google和Facebook登录按钮看起来均匀漂亮?请查看详细信息 [英] How to make default Google and Facebook login buttons look even and pretty? Please see details

查看:173
本文介绍了如何使默认的Google和Facebook登录按钮看起来均匀漂亮?请查看详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已提供在我的应用中使用google和facebook登录的选项.

I have given option to login with google and facebook in my app.

但是默认按钮看起来像这样不均匀且难看:

But the default buttons looks uneven and ugly like this:

这是xml代码:

<android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:contentPadding="10dp"
            app:cardElevation="2dp"
            app:cardBackgroundColor="@android:color/white">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <com.google.android.gms.common.SignInButton
                    android:id="@+id/google_login_button"
                    android:layout_width="@dimen/sign_in_btn_width"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal" />

                <com.facebook.login.widget.LoginButton
                    android:id="@+id/facebook_login_button"
                    android:layout_width="@dimen/sign_in_btn_width"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_between_google_facebook_signup_btn"
                    android:layout_gravity="center_horizontal" />

            </LinearLayout>

        </android.support.v7.widget.CardView>

如何使它们看起来均匀漂亮?

How can I make them look even and pretty?

请让我知道.

很抱歉,如果问题的格式似乎不正确.我只是这里的初学者.

Sorry if question seems to be badly formatted. I'm just a beginner here.

推荐答案

好的,我想出了解决方案.

Okay, I figured out the solution.

这是经过编辑的xml代码:

Here's edited xml code:

<LinearLayout
                android:layout_width="@dimen/sign_in_btn_width"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_gravity="center">

                <com.google.android.gms.common.SignInButton
                    android:id="@+id/google_login_button"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal" />

                <com.facebook.login.widget.LoginButton
                    android:id="@+id/facebook_login_button"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/sign_in_btn_height"
                    android:layout_marginTop="@dimen/margin_between_google_facebook_signup_btn"
                    android:layout_gravity="center_horizontal"
                    android:paddingTop="11dp"
                    android:paddingBottom="11dp"
                    android:paddingLeft="12dp"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    xmlns:facebook="http://schemas.android.com/apk/res-auto"
                    facebook:com_facebook_login_text="           Sign in"/>

            </LinearLayout>

        </android.support.v7.widget.CardView>

以下是Facebook登录按钮的Java代码:

Here's java code for facebook login button:

float fbIconScale = 1.10F;
        Drawable drawable = getBaseContext().getResources().getDrawable(
                com.facebook.R.drawable.com_facebook_button_icon);
        drawable.setBounds(0, 0, (int)(drawable.getIntrinsicWidth()*fbIconScale),
                (int)(drawable.getIntrinsicHeight()*fbIconScale));

        /* *************************************
         *              FACEBOOK               *
         ***************************************/
        /* Load the Facebook login button and set up the tracker to monitor access token changes */
        mFacebookCallbackManager = CallbackManager.Factory.create();
        mFacebookLoginButton = (LoginButton) findViewById(R.id.facebook_login_button);
        mFacebookLoginButton.setCompoundDrawables(drawable, null, null, null);

这是结果:

和平!

这篇关于如何使默认的Google和Facebook登录按钮看起来均匀漂亮?请查看详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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