JustifyTextView
最低版本: 1.14.1最后更新: 2020/10/26组件功能
可以多行滚动显示,高亮当前行的TextView。
支持平台:
平台 | 是否支持 |
豹小秘 | 是 |
豹大/花瓶 | 否 |
豹小秘 Mini | 是 |
参数
属性 | JS类型 | Java类型 | 默认值 | 必填 | 说明 | 最低版本 |
onChange | (event: any) => void | undefined | 否 | 内容变化回调事件 | 1.14.1 | |
params | { maxWidth: number; text: string; textSize: number; startTextColor?: string; endTextColor?: string} | null | 否 | 参数:{ maxWidth: 最大宽度;,默认值-1 text: 显示的内容; textSize: text 大小,默认值 70; startTextColor?: 渐变色,开始颜色,默认值 “#4BFFFFFF”; endTextColor?: 渐变色,结束颜色,默认值"#FFFFFFFF"} | 1.14.1 | |
onAnimationStart | (event: any) => void | undefined | 否 | 开始动画回调 | 1.14.1 | |
onAnimationRepeat | (event: any) => void | undefined | 否 | 结束动画回调 | 1.14.1 |
示例代码
<TouchableOpacity
activeOpacity={1.0} onPressIn={() => {
console.log("onPressIn");
}}>
<JustifyTextView
ref={(ref) => this.textRef = ref}
params={{maxWidth: width, text: item}}
style={{ height: this.state.realHeight }}
onChange={(event: any) => {
let realHeight = event.nativeEvent.height;
this.lineCount = event.nativeEvent.lineCount;
console.log('event-- realHeight=' + realHeight);
console.log('event-- lineCount=' + this.lineCount);
this.setState({
realHeight: realHeight / 3.5
});
if (!this.props.isReply) {
//全部高亮
this._dispatchCommand(JustifyTextType.SET_ALL_HIGH_LIGHT);
} else {
if (chatModel.isStopClickAutoTalk()
&& this.props.item.intent === Intent.chat) {
//全部高亮
this._dispatchCommand(JustifyTextType.SET_ALL_HIGH_LIGHT);
}
}
}}
onAnimationStart={(event: any) => {
console.log(TAG, 'onAnimationStart');
this._scrollToTop();
this.scrollY = 0;
}}
onAnimationRepeat={(event: any) => {
console.log(TAG, 'onAnimationRepeat');
this._startScrollAnimation();
}}
/>
</TouchableOpacity>