Google Login Layout - Android

I search everywhere and do not find what I want, I begin to think that it is impossible.

Here is the question: I have a google login button, it is a beautiful button, but it doesn’t fit my layout, I would like to use the image I created in the google button, for example what is going on in the image buttons, is this possible? If so, how can I do this?

thank

+2


source to share


2 answers


I have a question. I've tried this always for a custom SignIn button for google plus.

Try it, it is verified by me.

Here is the code.

xml layout

<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" />

      



Setting method

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;
        }
    }
}

      

Edit

Add this code before the return in the method googleBtnUi()

ViewGroup.LayoutParams params = tv.getLayoutParams();
params.width = 100;
params.height = 70;
tv.setLayoutParams(params);

      

+1


source


You can create your own button and use an XML tag android:drawableLeft="@drawable\file"

to show any image on the button.



0


source







All Articles