tencent cloud

Android Customization Capabilities

Download
Focus Mode
Font Size
Last updated: 2026-04-30 15:24:35

Custom prompts and new languages

Custom prompt

If you need to modify the prompts or add new language files, you can do so in the following way. The Identity Verification SDK provides a translation file custom_strings.xml, which contains all the configurable files that the Identity Verification SDK allows for external modification.

1. Open the main module (the module that integrates the SDK) project.
2. Add custom_strings.xml to the corresponding language folder.
3. Modify the text content that needs to be customized as needed.
4. After packaging, your modified content will automatically overwrite the pre-existing content.
└── src
└── main
├── AndroidManifest.xml
├── assets
├── java
└── res
├── values-zh-rCN
│ └── custom_strings.xml
└── values-zh-rHK
└── custom_strings.xml

Additional language

When adding a new language file, perform the following three steps to implement it:
1. Add the corresponding language folder in the main module project (the module integrating the Identity Verification SDK).
2. Copy custom_strings.xml to the target language folder and modify the corresponding value content.
└── src
└── main
├── AndroidManifest.xml
├── assets
├── java
└── res
├── values-th-rTH
│ └── custom_strings.xml <<<<<<<<<<< Taking Thai as an example, values-th-rTH
├── values-zh-rCN
│ └── custom_strings.xml
└── values-zh-rHK
└── custom_strings.xml
3. Specify the corresponding language code in the code (using Thai as an example).
EkycHyConfig ekycHyConfig = new EkycHyConfig();
ekycHyConfig.setLanguageStyle(LanguageStyle.CUSTOMIZE_LANGUAGE);
ekycHyConfig.setLanguageCode("th-TH");


Appendix: Android Language Codes

This document provides the following partial language codes for Android for reference.
Language code
Corresponding countries or regions of use
af-ZA
Dutch - South Africa
sq-AL
Albanian - Albania
ar-DZ
Arabic - Algeria
ar-BH
Arabic - Bahrain
ar-EG
Arabic - Egypt
ar-IQ
Arabic - Iraq
ar-JO
Arabic - Jordan
ar-KW
Arabic - Kuwait
ar-LB
Arabic - Lebanon
ar-LY
Arabic - Libya
ar-MA
Arabic - Morocco
ar-OM
Arabic - Oman
ar-QA
Arabic - Qatar
eu-ES
Basque - Basque
be-BY
Belarusian - Belarus
bg-BG
Bulgarian - Bulgaria
ca-ES
Catalan - Catalan
zh-HK
Chinese - Hong Kong (China)
zh-MO
Chinese - Macao (China)
zh-CN
Chinese - China
zh-SG
Chinese - Singapore
zh-TW
Chinese - Taiwan (China)
zh-CHS
Chinese (Simplified)
zh-CHT
Chinese (Traditional)
hr-HR
Croatian - Croatia
cs-CZ
Czech - Czech Republic
da-DK
Danish - Denmark
div-MV
Dhivehi - Maldives
nl-BE
Dutch - Belgium
nl-NL
Dutch - Netherlands
en-AU
English - Australia
en-CA
English - Canada
en-ZA
English - South Africa
en-PH
English - Philippines
en-NZ
English - New Zealand
en-GB
English - United Kingdom
en-US
English - United States
fa-IR
Persian - Iran
fi-FI
Finnish - Finland
fr-FR
French - France
fr-BE
French - Belgium
fr-MC
French - Monaco
fr-CH
French - Switzerland
gl-ES
Galician - Spain
ka-GE
Georgian - Georgia
de-DE
German - Germany
de-LU
German - Luxembourg
de-CH
German - Switzerland
el-GR
Greek - Greece
gu-IN
Gujarati - India
he-IL
Hebrew - Israel
hi-IN
Hindi - India
hu-HU
Hungarian - Hungary
is-IS
Icelandic - Iceland
it-IT
Italian - Italy
ja-JP
Japanese - Japan
kk-KZ
Kazakh - Kazakhstan
kn-IN
Kannada - India
ko-KR
Korean - South Korea
lv-LV
Latvian - Latvia
lt-LT
Lithuanian - Lithuania
ms-BN
Malay - Brunei
ms-MY
Malay - Malaysia
mr-IN
Marathi - India
mn-MN
Mongolian - Mongolia
nn-NO
Norwegian (Nynorsk) - Norway
pl-PL
Polish - Poland
pt-BR
Portuguese - Brazil
pt-PT
Portuguese - Portugal
ro-RO
Romanian - Romania
sa-IN
Sanskrit - India
ru-RU
Russian - Russia
sk-SK
Slovak - Slovakia
es-AR
Spanish - Argentina
es-ES
Spanish - Spain
sv-SE
Swedish - Sweden
th-TH
Thai - Thailand
tr-TR
Turkish - Türkiye
uk-UA
Ukrainian - Ukraine
ur-PK
Urdu - Pakistan
vi-VN
Vietnamese - Vietnam

Custom layout

The eKYC SDK supports customization of the OCR recognition interface and the selfie verification page layout. By configuring OcrUiConfig and FaceAuthUiConfig in EkycHyConfig, you can achieve complete UI customization.

The SDK provides two default layout files as reference templates in the resources/custom_layout/ directory:
ocr_detect_fragment.xml: Default layout for the OCR recognition page.
huiyan_fragment_authing.xml: Default layout for the selfie verification page.
We recommend modifying based on these two files to ensure the necessary View components and IDs remain consistent.


ocr_detect_fragment.xml Layout Specifications

ocr_detect_fragment.xml is the layout template for the OCR document recognition page, with the root layout as RelativeLayout.

The layout includes the following Views: the type (class) of all Views and android:id cannot be modified, but their position, size, color, and other attributes can be adjusted:
View ID
Type
Description
camera_surface_view
TextureView
Camera preview
ocr_mask_view
CameraMaskView
Document recognition frame and mask support style adjustments via custom attributes. For details, see below CameraMaskView custom attributes.
ocr_tips_tv
OcrDetectTipsView
Recognition prompt text, with real-time updates by the SDK
album_image_button
ImageButton
Album selection button
take_picture_button
ImageButton
Capture button
light_image_button
ImageButton
Flash toggle button
txy_detect_back
ImageView
Default back button (hidden by default, visibility controlled by the SDK)
When customizing, you can add any View (such as navigation bars) to the layout and bind events to newly added controls via the onMainViewCreate callback in setOcrEventCallBack().


CameraMaskView custom attributes

ocr_mask_view supports the following XML custom attributes (using the app: namespace):

Mask and Positioning

Required
Type
Description
txy_mask_color
color
Mask background color
txy_mask_margin
dimension
Mask margin, only effective when txy_position_flag="margin"
txy_position_flag
enum
Positioning mode for the recognition frame: center (centered) / margin (positioned by margin)

Top prompt text

Required
Type
Description
txy_tip_text
string
Prompt text content
txy_tip_color
color
Default state text color
txy_tip_light_color
color
Text color in highlighted state (when recognition succeeds)
txy_tip_error_color
color
Error state text color
txy_tip_size
dimension
Text size
txy_tip_margin
dimension
Spacing between text and recognition frame
txy_tip_show
boolean
Whether to display the prompt text
txy_tip_textStyle
flag
Font style: normal / bold / italic / bold_italic

Bottom prompt text

Required
Type
Description
txy_bottom_tips_txt
string
Bottom prompt text content
txy_bottom_tip_size
dimension
Bottom text size
txy_bottom_tip_color
color
Bottom text color
txy_bottom_tip_margin_top
dimension
Spacing between the bottom text and the bottom edge of the recognition frame
txy_bottom_tip_show
boolean
Whether to display the bottom prompt text
txy_bottom_tips_textStyle
flag
Font style: normal / bold / italic / bold_italic

Corner (corner of the recognition frame)

Required
Type
Description
txy_line_color
color
Corner line default color
txy_line_light_color
color
Highlight color when recognition succeeds
txy_line_error_color
color
Error state color
txy_line_width
dimension
Corner line width
txy_line_length
dimension
Corner line length
txy_line_padding
dimension
Spacing between the corner lines and the inner edge of the recognition frame
txy_line_margin
dimension
Spacing between the corner lines and the screen edge

Document type icon

Required
Type
Description
txy_front_head_icon
reference
Guidance icon for the portrait area on the front of the document
txy_front_head_scale_size
float
Portrait icon scaling ratio
txy_front_head_margin_top
dimension
Spacing between the portrait icon and the top edge of the recognition frame
txy_front_head_margin_right
dimension
Spacing between the portrait icon and the right edge of the recognition frame
txy_back_emblem_icon
reference
Guidance icon for the national emblem area on the back of the document
txy_back_emblem_scale_size
float
National emblem icon scaling ratio
txy_back_emblem_margin_top
dimension
Spacing between the national emblem icon and the top edge of the recognition frame
txy_back_emblem_margin_left
dimension
Spacing between the national emblem icon and the left edge of the recognition frame

Document Style and Layout Direction

Required
Type
Description
txy_maskView_view_type
flag
Document type styles: normal / id_front / id_back / hk_03 / hk_18 / hk_macao_pass
txy_mask_view_use_type
flag
Layout direction: portrait (vertical screen) / landscape (horizontal screen)
txy_rect_height_weight_hor
integer
Height ratio of the recognition frame in landscape mode

Scan Line Animation

Required
Type
Description
txy_is_show_scanline
boolean
Whether to display the scanning animated line
txy_scanline_animator_time
integer
Scanning line animation duration (ms)
txy_scanline_start_color
color
Scanning line starting gradient color
txy_scanline_mid_color
color
Scanning line middle gradient color
txy_scanline_end_color
color
Scanning line ending gradient color
txy_scanline_start_color_size_range
integer
Starting color gradient range
txy_scanline_start_to_mid_color_size_range
integer
Starting to middle color transition range
with OcrUiConfigoverlapping configuration items.
The following XML attributes have functionality overlap with the code configuration method of OcrUiConfig. When both are set simultaneously, the code configuration takes precedence and overrides the XML attributes:
XML attributes
OcrUiConfig method
Description
txy_line_color
setCardFrameDefaultColor()
Corner line default color
txy_line_light_color
setCardFrameColor()
Highlight color for successful recognition
txy_line_error_color
setWarnErrorTextColor()
Error state color
txy_tip_color
setDefaultTipTextColor()
Hint text default color
txy_tip_light_color
setSuccessRemindTextColor()
Prompt text highlight color
txy_tip_error_color
setWarnErrorTextColor()
Prompt text error color
txy_bottom_tips_txt
setBottomTipsContext()
Bottom prompt text content
Note:
It is recommended to use the OcrUiConfig configuration to prevent inconsistencies caused by setting both sides simultaneously.


huiyan_fragment_authing.xml layout description

huiyan_fragment_authing.xml is the layout template for the liveness verification page, with HuiYanReflectLayout (inherits from ConstraintLayout) as the root layout. The SDK overlays camera capture and animation logic on this layout.

The layout contains the following Views: the type (class) of all Views and android:id cannot be modified, but their position, size, color, and other attributes can be adjusted (it is not recommended to adjust txy_camera_gather_view, txy_auth_common_background_views, and txy_auth_loading_front_animator_view):
View ID
Type
Description
txy_auth_layout_bg
HuiYanReflectLayout
Root layout
txy_cancel_txt_btn
TextView
Cancel/Back button, the SDK binds a click event to exit the liveness verification process.
txy_count_down_txt_view
TextView
Countdown text, the SDK controls its visibility and content.
txy_auth_feed_back_txt
TextView
Liveness verification main prompt text, with real-time updates by the SDK.
txy_camera_gather_view
CameraDateGatherView
Camera preview
txy_auth_common_background_views
CommonAuthBackView
Face circle background animation
txy_camera_prepare_img
ImageView
Preparation phase avatar guide image
txy_auth_loading_front_animator_view
LoadingFrontAnimatorView
Loading foreground animation
txy_auth_feed_back_extra_tip_txt
TextView
Secondary prompt text (additional warning message)
txy_hud_view
HudView
Glare detection secondary prompt view
Custom layouts can add any Views (such as navigation bars) and bind events to new controls via the onMainViewCreate callback in setAuthEventCallBack().


Custom Layout for the OCR Page

The custom layout for the OCR recognition page is implemented via OcrUiConfig.setPortraitLayoutResId() by passing in the Resource ID of the custom layout:
EkycHyConfig ekycHyConfig = new EkycHyConfig();

OcrUiConfig ocrUiConfig = new OcrUiConfig();
ocrUiConfig.setPortraitLayoutResId(R.layout.custom_ocr_layout);

ekycHyConfig.setOcrUiConfig(ocrUiConfig);
Note:
Custom layouts must retain the necessary View components required by the OCR SDK. Do not modify the type or android:id of these Views. It is recommended to modify using ocr_detect_fragment.xml as a template.


Custom layout for the liveness face verification page

The custom layout for the liveness verification page is implemented via FaceAuthUiConfig.setAuthLayoutResId() by passing in the Resource ID of the custom layout:
EkycHyConfig ekycHyConfig = new EkycHyConfig();

FaceAuthUiConfig faceAuthUiConfig = new FaceAuthUiConfig();
faceAuthUiConfig.setAuthLayoutResId(R.layout.custom_face_auth_layout);

ekycHyConfig.setFaceAuthUiConfig(faceAuthUiConfig);
Note:
When the liveness verification layout is customized, the type and android:id of all Views must match those required by the selfie verification SDK, as these Views participate in interface event binding. It is recommended to modify using huiyan_fragment_authing.xml as a template.


Event Binding for Custom Layouts

When the layout is customized, you can bind events to newly added UI controls via the setAuthEventCallBack() method. When the main interface for liveness face detection is created, the HuiYanAuthEventCallBack.onMainViewCreate(View) method is called back. At this point, you can obtain controls from the custom layout and register event listeners:
EkycHySdk.setAuthEventCallBack(new HuiYanAuthEventCallBack() {
@Override
public void onMainViewCreate(View authView) {
if (authView == null) {
return;
}
// Obtain controls in the custom layout
Button customButton = authView.findViewById(R.id.custom_button_id);
if (customButton != null) {
customButton.setOnClickListener(v -> {
// Handle custom button click events
Log.d(TAG, "Custom button clicked");
});
}
}

@Override
public void onMainViewDestroy() {
// Cleanup upon page destruction
Log.d(TAG, "Auth view destroyed");
}
});

Similarly, for the custom layout of the OCR recognition interface, you can bind events to newly added UI controls via the setOcrEventCallBack() method:
EkycHySdk.setOcrEventCallBack(new OcrEventListener() {
@Override
public void onMainViewCreate(View ocrView) {
if (ocrView == null) {
return;
}
// Obtain controls in the custom OCR layout
Button customOcrButton = ocrView.findViewById(R.id.custom_ocr_button_id);
if (customOcrButton != null) {
customOcrButton.setOnClickListener(v -> {
// Handle custom button click events
Log.d(TAG, "Custom OCR button clicked");
});
}
}

@Override
public void onMainViewDestroy() {
// Cleanup upon page destruction
Log.d(TAG, "OCR view destroyed");
}
});


Best Practices: Custom Navigation Bar

The following example shows how to add a custom navigation bar at the top of the liveness verification page, including a back button and a title.

Step 1: Add a new navigation bar in the layout

Based on huiyan_fragment_authing.xml, place the originally independent txy_cancel_txt_btn into the navigation bar container and add a title text. Note that the ID of txy_cancel_txt_btn must be retained, as the SDK will automatically bind a click event to it to exit the liveness verification process.
<!-- Custom navigation bar container, where background color and height can be freely configured -->
<FrameLayout
android:id="@+id/custom_nav_bar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#2196F3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<!-- Back button: The ID must be txy_cancel_txt_btn, as the SDK will bind the exit event to it -->
<TextView
android:id="@+id/txy_cancel_txt_btn"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="15dp"
android:background="@drawable/ic_arrow_left" />

<!-- Custom title: The ID can be customized, and the text needs to be updated in onMainViewCreate -->
<TextView
android:id="@+id/custom_nav_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Face Verification"
android:textColor="@android:color/white"
android:textSize="18sp" />

</FrameLayout>
Step 2: Configure the custom layout and launch the SDK
FaceAuthUiConfig faceAuthUiConfig = new FaceAuthUiConfig();
faceAuthUiConfig.setAuthLayoutResId(R.layout.custom_face_auth_layout);
faceAuthUiConfig.setStatusBarColor(color); // Set the status bar background color, usually consistent with the custom navigation bar's background

EkycHyConfig ekycHyConfig = new EkycHyConfig();
ekycHyConfig.setFaceAuthUiConfig(faceAuthUiConfig);




Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback