Explorar el Código

优化歌词效果

onecold hace 7 meses
padre
commit
91e25cc0c6
Se han modificado 1 ficheros con 10 adiciones y 10 borrados
  1. 10 10
      lib/src/main/ets/view/LyricView2.ets

+ 10 - 10
lib/src/main/ets/view/LyricView2.ets

@@ -297,14 +297,14 @@ export struct LyricView2 {
                     y: index == this.currentIndex ? this.controller.getHighlightScale() : 1,
                     centerX: this.alignMode == 'center' ? '50%' : 0
                 })
-                .maxLines(1)
-                .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
                 .fontColor(index == this.currentIndex ? this.textHighlightColor : this.textColor)
                 .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
                 .animation({
                     duration: 150,
                     curve: Curve.Linear
                 })
+                .heightAdaptivePolicy(TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST)
+                .padding({ top:5,bottom:5 })
                 .blendMode(
                     index == this.currentIndex ? BlendMode.DST_IN : undefined,
                     index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
@@ -312,7 +312,7 @@ export struct LyricView2 {
                 .visibility(this.isSingleLine?
                     (index == this.currentIndex ?Visibility.Visible:Visibility.None)
                     :Visibility.Visible)
-                .width(this.alignMode == 'center' ? '95%' : '90%')
+                .width(this.alignMode == 'center' ? '95%' : '85%')
 
             // 中文翻译(整行显示)
             if (item.translation)  {
@@ -322,9 +322,7 @@ export struct LyricView2 {
                         .fontColor(this.currentMediaPosition >= item.beginTime ?
                             index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
                         .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
-                        .margin({ top: 4 })
-                        .maxLines(1)
-                        .textOverflow({ overflow: TextOverflow.MARQUEE })//超长滚动
+                        .padding({ bottom:5 })
                         .animation({
                             duration: 150,
                             curve: Curve.Linear
@@ -335,7 +333,7 @@ export struct LyricView2 {
                         )
                 }
                 .justifyContent(this.alignMode === 'center' ? FlexAlign.Center : FlexAlign.Start)
-                .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '90%')
+                .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '85%')
             }
         }
         // 在 Row 上应用渐变
@@ -465,6 +463,7 @@ export struct LyricView2 {
                         .visibility(this.isSingleLine?
                             (index == this.currentIndex ?Visibility.Visible:Visibility.None)
                             :Visibility.Visible)
+                        .padding({ top:5,bottom:5 })
                         .shaderStyle(index == this.currentIndex ?{
                             direction: GradientDirection.Right,
                             colors: this.getWordByWordLyricLyricItemLinearGradient(item, word, index)
@@ -480,7 +479,7 @@ export struct LyricView2 {
                 })
             }
             .justifyContent(this.alignMode === 'center' ? FlexAlign.Center : FlexAlign.Start)
-            .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '90%')
+            .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '85%')
 
             // 中文翻译(整行显示)
             if (item.translation)  {
@@ -490,12 +489,13 @@ export struct LyricView2 {
                         .fontColor(this.currentMediaPosition >= item.beginTime ?
                             index == this.currentIndex ? this.textHighlightColor : this.textColor : this.textColor)
                         .fontWeight(index == this.currentIndex? FontWeight.Bold : this.textWeight)
-                        .margin({ top: 4 })
+                        .padding({ bottom:5 })
                 }
                 .justifyContent(this.alignMode === 'center' ? FlexAlign.Center : FlexAlign.Start)
-                .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '90%')
+                .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '85%')
             }
         }
+        .height('auto')
 
 
     }