Layout Google Sign In Button - Android

前端 未结 3 563
难免孤独
难免孤独 2021-01-03 04:54

I\'m searching everywhere and not finding what I want, I\'m starting to think that this is impossible.

Here\'s the question: I have a google button for sign in, it\'

3条回答
  •  没有蜡笔的小新
    2021-01-03 05:05

    I have your question solution. I tried this always for custom SignIn Button for google plus.

    Try this it is tested by me.

    Here is the Code.

    xml layout

    
    

    Method for customisation

    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 return in method googleBtnUi()

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

提交回复
热议问题