└── src└── main├── AndroidManifest.xml├── assets├── java└── res├── values-zh-rCN│ └── custom_strings.xml└── values-zh-rHK└── custom_strings.xml
└── 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
cloudConfig.setLanguageStyle(LanguageStyle.CUSTOMIZE_LANGUAGE);cloudConfig.setLanguageCode("th-TH");
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 |
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.res/layout/, res/drawable/, res/values/).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 |
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 |
txy_action_left_ib / txy_action_title_tv.res/layout/ directory, and pass the resource id to the SDK before startup:CustomConfigUi customConfigUi = new CustomConfigUi();// Custom portrait layoutcustomConfigUi.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);
CustomConfigUi.INIT_INT_VALUE is retained), the SDK uses the built-in default layout.IOcrCloudEventListener#onMainViewCreate and register events yourself:OcrOverseasCloudKit.getInstance().setCloudEventListener(new IOcrCloudEventListener() {@Overridepublic 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"));}}}@Overridepublic void onMainViewDestroy() {// Callback for page termination (main thread). Release all references here to avoid memory leaks.}@Overridepublic void onEventParamMap(HashMap<String, Object> map) {// Pass through additional parameters}});
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.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 |
CustomConfigUi configuration takes precedence (for example, cardFrameColor, titleBarText, and isShowTips will override the XML values after the page is created).Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback