HuaweiIdAuthButton is a button control provided by Account Kit. This control displays the sign-in buttons in Huawei style, helping you quickly implement a sign-in button that complies with HUAWEI ID Sign-In Button Usage Rules. Note that this control deals with only the display effects of the button. To trigger the sign-in action, use setOnClickListener(OnClickListener) to register a listener.
Device Type | OS Version | HMS Core (APK) Version |
|---|---|---|
Phone and tablet | EMUI 3.0 or later and Android 4.4 or later | 4.0.0.300 or later |
Configure app information in AppGallery Connect and integrate the HMS Core SDK. After that, you can use HuaweiIdAuthButton.
HuaweiIdAuthButton requires HMS Core SDK 4.0.0.300 or later.
Similar to common controls, HuaweiIdAuthButton can be used in two ways. One is to declare the control in the layout XML file. The other is to create an instance of the HuaweiIdAuthButton class in Java or Kotlin code and dynamically add the instance to the layout. You can select a method as needed.
Control Declaration
Declare the HuaweiIdAuthButton control as follows:
<com.huawei.hms.support.hwid.ui.HuaweiIdAuthButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/> UI example:

Standard text on a button is Sign in with HUAWEI ID, which cannot be changed.
After declaring the control in the layout file, use setOnClickListener(OnClickListener) to register a listener in Java or Kotlin code and perform the sign-in operation in the listening event.
Parameter Customization
The following table lists the customized style-related parameters provided by HuaweiIdAuthButton.
Parameter | Option | Description |
|---|---|---|
hwid_button_theme | hwid_button_theme_full_title | The button contains both icon and text. |
hwid_button_theme_no_title | The button contains no text. | |
hwid_color_policy | hwid_color_policy_black | The button color is black. |
hwid_color_policy_gray | The button color is gray. This option is available only when hwid_button_theme is set to hwid_button_theme_full_title. | |
hwid_color_policy_red | The button color is red. | |
hwid_color_policy_white | The button color is white. | |
hwid_color_policy_white_with_border | The button has white borders. This option is available only when hwid_button_theme is set to hwid_button_theme_full_title. | |
hwid_corner_radius | hwid_corner_radius_large | The button has large rounded corners. |
hwid_corner_radius_medium | The button has medium rounded corners. | |
hwid_corner_radius_small | The button has small rounded corners. |
Reference the namespace in the layout file:
xmlns:app="http://schemas.android.com/apk/res-auto"
The following is an example of using the customized parameters:
<com.huawei.hms.support.hwid.ui.HuaweiIdAuthButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:hwid_button_theme="hwid_button_theme_full_title"
app:hwid_color_policy="hwid_color_policy_red"
app:hwid_corner_radius="hwid_corner_radius_large"
/> UI example:

Standard text on a button is Sign in with HUAWEI ID, which cannot be changed.
Control Declaration
Use the constructors of HuaweiIdAuthButton to create an instance and add HuaweiIdAuthButton to the layout using addView.
Constructor | Description |
|---|---|
HuaweiIdAuthButton(Context context) | Constructor for creating a HuaweiIdAuthButton instance. |
HuaweiIdAuthButton(Context context, AttributeSet attributeSet) | Constructor for creating a HuaweiIdAuthButton instance and loading a style based on the attribute set. |
HuaweiIdAuthButton(Context context, AttributeSet attributeSet, int defStyleAttr) | Constructor for creating a HuaweiIdAuthButton instance and specifying the default style. |
Sample code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_sign_in_api"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
</LinearLayout> Java
HuaweiIdAuthButton huaweiIdAuthButton = new HuaweiIdAuthButton(this);
LinearLayout layout = findViewById(R.id.layout_sign_in_api);
layout.addView(huaweiIdAuthButton); Kotlin
val huaweiIdAuthButton = HuaweiIdAuthButton(this)
val layout = findViewById<LinearLayout>(R.id.layout_sign_in_api)
layout.addView(huaweiIdAuthButton) Parameter Customization
The following table lists the customized style-related parameters provided by HuaweiIdAuthButton.
Parameter Customization Method | Option | Description |
|---|---|---|
setTheme(int theme) | HuaweiIdAuthButton.THEME_FULL_TITLE | The button contains both icon and text. |
HuaweiIdAuthButton.THEME_NO_TITLE | The button contains no text. | |
setColorPolicy(int colorPolicy) | HuaweiIdAuthButton.COLOR_POLICY_BLACK | The button color is black. |
HuaweiIdAuthButton.COLOR_POLICY_GRAY | The button color is gray. This option is available only when the theme is set to THEME_FULL_TITLE. | |
HuaweiIdAuthButton.COLOR_POLICY_RED | The button color is red. | |
HuaweiIdAuthButton.COLOR_POLICY_WHITE | The button color is white. | |
HuaweiIdAuthButton.COLOR_POLICY_WHITE_WITH_BORDER | The button has white borders. This option is available only when the theme is set to THEME_FULL_TITLE. | |
setCornerRadius(int cornerRadiusPx) | HuaweiIdAuthButton.CORNER_RADIUS_LARGE | The button has large rounded corners. |
HuaweiIdAuthButton.CORNER_RADIUS_MEDIUM | The button has medium rounded corners. | |
HuaweiIdAuthButton.CORNER_RADIUS_SMALL | The button has small rounded corners. | |
setUIMode(int theme, int colorPolicy, int cornerRadius) | See the options of theme, colorPolicy, and cornerRadius. | Sets the theme, color, and rounded corner radius of HuaweiIdAuthButton. |
setEnabled(boolean flag) | true/false | Sets whether a button can be tapped. |
Sample code:
Java
HuaweiIdAuthButton huaweiIdAuthButton = new HuaweiIdAuthButton(this);
huaweiIdAuthButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Process operations during sign-in.
}
});
huaweiIdAuthButton.setTheme(HuaweiIdAuthButton.THEME_FULL_TITLE);
huaweiIdAuthButton.setColorPolicy(HuaweiIdAuthButton.COLOR_POLICY_RED);
huaweiIdAuthButton.setCornerRadius(HuaweiIdAuthButton.CORNER_RADIUS_LARGE);
LinearLayout layout = findViewById(R.id.layout_sign_in_api);
layout.addView(huaweiIdAuthButton); Kotlin
val huaweiIdAuthButton = HuaweiIdAuthButton(this)
huaweiIdAuthButton.setOnClickListener {
// Process operations during sign-in.
}
huaweiIdAuthButton.theme = HuaweiIdAuthButton.THEME_FULL_TITLE
huaweiIdAuthButton.colorPolicy = HuaweiIdAuthButton.COLOR_POLICY_RED
huaweiIdAuthButton.cornerRadius = HuaweiIdAuthButton.CORNER_RADIUS_LARGE
val layout = findViewById<LinearLayout>(R.id.layout_sign_in_api)
layout.addView(huaweiIdAuthButton)