Android 定制指南(原生内核)

最近更新时间:2026-03-18 16:41:02

我的收藏
说明:
阅读本文前,请确保您已经了解并完成了 接入准备原生内核(Android)快速接入 的基础集成。
SDK 支持高度自定义课堂内的 UI(如头部导航栏、消息气泡等)。以下以自定义头部左侧组件为例。

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. 绑定自定义 View
headerConfig.setHeaderLeftBuilder(::HeaderLeftViewCreator)

// 3. 写入全局配置并进房
val config = TCICConfig(token, classId, userId, role)
config.headerComponentConfig = headerConfig
TCICManager.setConfig(config)

context.startActivity(TCICManager.getTCICIntent(context))

附:支持自定义的组件列表

您可以根据业务需求,对以下模块进行自定义替换:
头部组件 (TCICHeaderComponentConfig):左侧视图、中间视图、右侧视图、操作按钮。
消息组件 (TCICMessageComponentConfig):消息列表头部、消息气泡、单条消息 Item。
音视频组件 (TCICVideoComponentConfig):视频操作栏、悬浮视频窗口。