Android Google plus login button style

2019-02-10 04:05发布

I need the long style button for google+ signin in android.

According to the Branding guidelines here there are different styles for the button like long, medium, short etc

I am getting the medium style button with help of the sample app, But I want the long style button.

here is my button `

   <com.google.android.gms.common.SignInButton
        android:id="@+id/sign_in_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:visibility="visible" />

`

3条回答
等我变得足够好
2楼-- · 2019-02-10 04:52

You can do it with XML by adding & using the app namespace (as they are custom attributes):

<com.google.android.gms.common.SignInButton
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/sign_in_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      app:buttonSize="wide"
      app:colorScheme="dark"
      />

Possible attributes values are:

  • buttonSize: "wide", "icon_only" or "standard"(default)
  • colorScheme: "dark", "light" & "auto"(default)
查看更多
Luminary・发光体
3楼-- · 2019-02-10 04:53

As the website described there are 3 sized button

  1. Icon only = SignInButton.SIZE_ICON_ONLY
  2. Normal button = SignInButton.SIZE_STANDARD
  3. Wide button = SignInButton.SIZE_WIDE

You can use it like this.

gSignInButton = (SignInButton) findViewById(R.id.sign_in_button);
gSignInButton.setOnClickListener(this);
gSignInButton.setEnabled(true);
gSignInButton.setSize(SignInButton.SIZE_WIDE);// wide button style
查看更多
爷的心禁止访问
4楼-- · 2019-02-10 05:02

You can use the setSize method of the Signin button to update the size.

For example, in my activity's onCreate method:

    mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);
    mSignInButton.setOnClickListener(this);
    mSignInButton.setSize(SignInButton.SIZE_WIDE);

will change the Sign-In button to be wide.

You can also just use ANY button that is appropriately branded by just using a Button and then using the activity as the button's click handler.

查看更多
登录 后发表回答