注意:说明:
注意:阅读这篇前,请确保你已经了解并完成了 接入准备 和 原生内核(Android)快速接入 的基础集成。
一、1. 创建自定义 View (Java 示例)
实现 NativeViewCreator 接口,编写你的原生 Android View:
public class HeaderLeftViewCreator implements NativeViewCreator { @Override public View createView(Context context, int id, Object args) { // 创建一个水平布局 LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setGravity(Gravity.CENTER_VERTICAL); // 添加自定义文字 TextView textView = new TextView(context); textView.setText("自定义头部"); textView.setTextColor(Color.WHITE); layout.addView(textView); // 添加自定义图标 ImageView infoIcon = new ImageView(context); infoIcon.setImageResource(android.R.drawable.ic_menu_info_details); layout.addView(infoIcon); return layout; } @Override public void disposeView(View view) { // 页面销毁时的资源清理工作 }}
二、2. 将自定义 View 注册到配置中
在进房前,将写好的 Creator 赋值给 TCICConfig:
// 1. 实例化头部配置val headerConfig = TCICHeaderComponentConfig()// 2. 绑定自定义 ViewheaderConfig.setHeaderLeftBuilder(::HeaderLeftViewCreator)// 3. 写入全局配置并进房val config = TCICConfig(token, classId, userId, role)config.headerComponentConfig = headerConfigTCICManager.setConfig(config)context.startActivity(TCICManager.getTCICIntent(context))
三、附:支持自定义的组件列表
你可以根据业务需求,对以下模块进行自定义替换:
·头部组件 (TCICHeaderComponentConfig):左侧视图、中间视图、右侧视图、操作按钮。
·消息组件 (TCICMessageComponentConfig):消息列表头部、消息气泡、单条消息 Item。
·音视频组件 (TCICVideoComponentConfig):视频操作栏、悬浮视频窗口。