Android 如何在 G+ 登录按钮中心设置文本视图

How to set textview in center of G+ sign in button in Android

我的代码中有 G+ 登录按钮,它可以正常登录。 我在 xml

中使用以下代码设置它
<com.google.android.gms.common.SignInButton
            android:id="@+id/btn_sign_in"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:textSize="15dp"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            />

我现在的情况如下

现在我想将 TextView 设置为按钮中心。但是,SignInButton 似乎没有 android:gravity 如何将我的 TextView 设置为居中?

@Karan - 在下面使用 code,它对我有用。

    SignInButton signInButton = ((SignInButton) findViewById(R.id.btn_sign_in));


    for (int i = 0; i < signInButton.getChildCount(); i++) {
        View v = signInButton.getChildAt(i);

        if (v instanceof TextView) {
            TextView tv = (TextView) v;
            tv.setPadding(0, 0, 20, 0);
            return;
        }
    }
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="@dimen/activity_horizontal_margin"
                android:layout_marginLeft="@dimen/small_margin"
                android:layout_marginRight="@dimen/small_margin"
                android:layout_marginTop="@dimen/activity_horizontal_margin"
                app:cardCornerRadius="@dimen/small_margin">

                <RelativeLayout
                    android:id="@+id/sign_google"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/white"
                    android:padding="@dimen/text_padding">

                    <ImageButton
                        android:id="@+id/img"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@color/white"
                        android:src="@drawable/googleg_standard_color_18" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_marginLeft="@dimen/small_margin"
                        android:layout_toRightOf="@+id/img"
                        android:gravity="center"
                        android:text="@string/sign_in"
                        android:textColor="@color/black" />
                </RelativeLayout>
            </android.support.v7.widget.CardView>