tencent cloud

eKYC

Android Customization Capabilities

Download
Focus Mode
Font Size
Last updated: 2026-10-21 15:51:48
AI-Translated

Custom Prompts and New Languages

Custom Prompts

If you need to modify the prompt messages or add new language files, you can do so by following the steps below. The SDK provides a translation file, custom_strings.xml, which contains all the configurable files that the Card Verification SDK exposes for modification.
1. Open the main module project (the module that integrates the SDK).
2. Add custom_strings.xml to the corresponding language folder.
3. Modify the text content that needs to be customized.
4. After packaging, your modified content will automatically overwrite the original content.
└── src
└── main
├── AndroidManifest.xml
├── assets
├── java
└── res
├── values-zh-rCN
│ └── custom_strings.xml
└── values-zh-rHK
└── custom_strings.xml

Adding a New Language

To add a new language file, perform the following three steps:
1. In the main module project (the module that integrates the Card Verification SDK), create the corresponding language folder.
2. Copy custom_strings.xml to the language folder and modify the corresponding value content.
└── src
└── main
├── AndroidManifest.xml
├── assets
├── java
└── res
├── values-th-rTH
│ └── custom_strings.xml <<<<<<<<<<< For example, for Thai, use values-th-rTH.
├── values-zh-rCN
│ └── custom_strings.xml
└── values-zh-rHK
└── custom_strings.xml
3. Specify the corresponding language code in your code. For example, use Thai as an example.
cloudConfig.setLanguageStyle(LanguageStyle.CUSTOMIZE_LANGUAGE);
cloudConfig.setLanguageCode("th-TH");


Appendix: Android Language Codes

This document provides some Android language codes below for your reference.
Language Code
Country or Region
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 - Catalonia
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 - Czechia
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 UI Layouts

The capture page of Token mode (OcrOverseasCloudKit) reuses the same set of Activity / Fragment components as the "full-process integration" mode. Therefore, the custom UI layout capability is fully available in Token mode. You only need to pass CustomConfigUi through OcrCloudConfig#setCustomConfigUi for it to take effect.


1. Obtaining the Default Layout File

The SDK provides a default portrait layout demo_ocr_detect_fragment.xml and a landscape layout demo_ocr_detect_hor_fragment.xml. Integrators can modify the UI based on these layouts.

Related resources can be obtained from the res folder in the delivery package (res/layout/, res/drawable/, res/values/).
Attention:
Do not delete or modify the default views or their corresponding IDs. Otherwise, the SDK cannot bind the controls, which may cause the capture page to behave abnormally or crash directly. You can freely adjust the position and style of the default layout, or add your own views.

2. view IDs That Must Be Retained in the Layout

Portrait layout (portraitLayoutResId):

view id
Control Type
Function
Required
camera_surface_view
TextureView
Camera preview
Required
ocr_mask_view
com.tencent.ocr.sdk.component.CameraMaskView
Mask layer and recognition frame
Required
ocr_tips_tv
com.tencent.ocr.sdk.component.OcrDetectTipsView
Real-time prompt text
Required
take_picture_button
ImageButton
Manual capture button
Required
album_image_button
ImageButton
Album image selection button
Required
light_image_button
ImageButton
Flash button
Required
txy_detect_back
ImageView
Floating back button
Required
txy_action_bar_rl
RelativeLayout
Title bar root layout
Required when the title bar is used
txy_action_left_ib
ImageButton
Title bar back button
Required when the title bar is used
txy_action_title_tv
TextView
Title bar title text
Required when the title bar is used
Landscape layout (landscapeLayoutResId, which requires setting isLandscape = true):

view id
Control Type
Function
Required
camera_surface_land_view
TextureView
Camera preview
Required
ocr_hor_mask_view
com.tencent.ocr.sdk.component.CameraMaskView
Mask layer and recognition frame
Required
ocr_tips_tv_land
com.tencent.ocr.sdk.component.OcrDetectTipsView
Real-time prompt text
Required
take_picture_button_land
ImageButton
Manual capture button
Required
album_image_button_land
ImageButton
Album image selection button
Required
txy_ocr_light_off_land
ImageButton
Flash button
Required
txy_land_back_action_btn
ImageView
Back button
Required
txy_action_left_ib
ImageButton
Title bar back button
Required when the title bar is used
txy_action_title_tv
TextView
Title bar title text
Required when the title bar is used
Note:
The default landscape layout does not include a title bar. If you need a title bar, you can include a sub-layout that contains txy_action_left_ib / txy_action_title_tv.

3. Setting a Custom Layout

Place the modified layout file in your module's res/layout/ directory, and pass the resource id to the SDK before startup:

CustomConfigUi customConfigUi = new CustomConfigUi();
// Custom portrait layout
customConfigUi.setPortraitLayoutResId(R.layout.demo_ocr_detect_fragment);
// Custom landscape layout (landscape mode must also be enabled)
customConfigUi.setLandscape(true);
customConfigUi.setLandscapeLayoutResId(R.layout.demo_ocr_detect_hor_fragment);

OcrCloudConfig config = new OcrCloudConfig();
config.setSdkToken(sdkToken);
config.setServerParamInfo(serverParamInfo);
config.setCustomConfigUi(customConfigUi);
OcrOverseasCloudKit.getInstance().startCloudOcr(activity, config, resultListener);

If this parameter is not set (the default value CustomConfigUi.INIT_INT_VALUE is retained), the SDK uses the built-in default layout.


4. Operating Newly Added Views in a Custom Layout

If you add views to the default layout and need to control them, you can obtain the root view of the page through IOcrCloudEventListener#onMainViewCreate and register events yourself:

OcrOverseasCloudKit.getInstance().setCloudEventListener(new IOcrCloudEventListener() {
@Override
public void onMainViewCreate(View mainView) {
// Callback for page creation (main thread)
if (mainView != null) {
Button button = mainView.findViewById(R.id.demo_test_button);
// Registration and handling of button events. Remember to check whether the View is null.
if (button != null) {
button.setOnClickListener(v -> Log.d(TAG, "click"));
}
}
}

@Override
public void onMainViewDestroy() {
// Callback for page termination (main thread). Release all references here to avoid memory leaks.
}

@Override
public void onEventParamMap(HashMap<String, Object> map) {
// Pass through additional parameters
}
});
Attention:
In Token mode, use OcrOverseasCloudKit#setCloudEventListener instead of OcrSDKKit#setOcrEventListener from the full-process mode. In Token mode, the SDK occupies this listener internally, so settings made by the business party will be overwritten.

5. CameraMaskView Properties

CameraMaskView is the main component for the recognition frame and mask. It can be configured directly through attributes in the layout xml. The currently supported attributes are as follows:

Property Name
Format
Meaning
txy_mask_color
color|reference
Mask layer color
txy_tip_text
string|reference
Prompt text above the recognition box
txy_tip_show
boolean
Display upper prompt text or not
txy_tip_color
color|reference
Tip text color
txy_tip_light_color
color|reference
Highlight color of tip text
txy_tip_error_color
color|reference
Tip text color in abnormal state
txy_tip_size
integer|dimension
Tip text size
txy_tip_margin
integer|dimension
Spacing between the bottom of the tip text and the recognition box
txy_tip_textStyle
flag
Tip text font: normal/bold/italic/bold_italic
txy_bottom_tips_txt
string|reference
tips text content below the recognition box
txy_bottom_tip_show
boolean
Display lower tips or not
txy_bottom_tip_color
color|reference
Lower tips text color
txy_bottom_tip_size
integer|dimension
Lower tips text size
txy_bottom_tip_margin_top
integer|dimension
Top spacing between lower tips and the recognition box
txy_bottom_tips_textStyle
flag
Lower tips font: normal/bold/italic/bold_italic
txy_line_color
color|reference
Default color of the recognition frame border
txy_line_light_color
color|reference
Highlight color of the recognition frame border when selected
txy_line_error_color
color|reference
Color of the recognition frame border in abnormal state
txy_line_width
integer|dimension
Border width (thickness)
txy_line_length
integer|dimension
Border length
txy_line_padding
integer|dimension
Spacing between the border and the inner transparent box
txy_line_margin
integer|dimension
Spacing between the border and the screen frame
txy_front_head_icon
reference
Placeholder icon for the portrait on the front of the ID card
txy_front_head_margin_top
integer|dimension
Top margin of the portrait icon
txy_front_head_margin_right
integer|dimension
Right margin of the portrait icon
txy_back_emblem_icon
reference
Placeholder icon for the national emblem on the back of the ID card
txy_back_emblem_margin_top
integer|dimension
Top margin of the national emblem icon
txy_back_emblem_margin_left
integer|dimension
Left margin of the national emblem icon
txy_maskView_view_type
flag
Recognition box type: normal/id_front/id_back/hk_03/hk_18/hk_macao_pass
txy_position_flag
enum
Recognition box position: center (centered)/margin (positioned by margin)
txy_mask_margin
integer|dimension
Positioning margin of the recognition box, effective only when txy_position_flag=margin
txy_mask_view_use_type
flag
Mask usage scenario: portrait (portrait)/landscape (landscape)
txy_rect_height_weight_hor
integer
Proportion of the middle height of the recognition box in landscape mode
txy_is_show_scanline
boolean
Display internal scanline or not
txy_scanline_start_color
color|reference
Start color of the scanline
txy_scanline_mid_color
color|reference
Transition color of the scanline
txy_scanline_end_color
color|reference
End color of the scanline
txy_scanline_animator_time
integer
Duration of one scanline animation
txy_scanline_start_color_size_range
integer
Coverage range of the start color
txy_scanline_start_to_mid_color_size_range
integer
Gradient range from the start color to the transition color
Attention:
If XML attributes conflict with the attributes passed through CustomConfigUi, the CustomConfigUi configuration takes precedence (for example, cardFrameColor, titleBarText, and isShowTips will override the XML values after the page is created).






Help and Support

Was this page helpful?

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

Feedback