HarmonyOS 定时轮播滚动的功能有没有用例代码

HarmonyOS
2024-12-18 16:40:34
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
shlp
@Entry
@Component
struct TextInputDemos {
  private swiperController: SwiperController = new SwiperController();
  private controller: TextInputController = new TextInputController()
  private textArr: String[] = ["早起晨练", "准备早餐", "阅读名著", "学习ArkTS", "看剧放松"]
  @State shuRu: boolean = false;
  @State text: string = '';

  build() {
    Column({ space: 5 }) {
      Stack() {
        TextInput({
          text: $$this.text, placeholder: '', controller: this.controller
        })
          .onChange((value: string) => {
            this.shuRu = true;
            if (value === '') {
              this.shuRu = false;
            }
          })
          .border({ width: 1 })
          .width('100%')
          .height(50)
          .zIndex(1)
        Swiper(this.swiperController) {
          ForEach(this.textArr, (item: string) => {
            Text(item.toString())
              .width('100%')
              .height(160)
              .backgroundColor('#00000000')
              .textAlign(TextAlign.Center)
              .fontSize(30)
              .fontWeight(2)
              .fontColor(Color.Gray)
          }, (item: string) => item)
        }
        .cachedCount(2)
        .index(0)
        .autoPlay(true)
        .interval(4000)
        .loop(true)
        .duration(1000)
        .itemSpace(0)
        .curve(Curve.Linear)
        .indicator(false)
        .vertical(true)
        .width('100%')
        .height(50)
        .visibility(this.shuRu ? Visibility.Hidden : Visibility.Visible)
      }
    }.width('100%').margin({ top: 5 })
  }
}
分享
微博
QQ
微信
回复
2024-12-18 18:50:26
相关问题
关于WebView提示没有用户手势问题
10732浏览 • 1回复 待解决
HarmonyOS 直播功能指南与样代码
468浏览 • 1回复 待解决
HarmonyOS有没有通用工具类Demo
771浏览 • 1回复 待解决
HarmonyOS 有没有指纹登录功能
622浏览 • 1回复 待解决
HarmonyOS 有没有类似maven包管理功能
788浏览 • 1回复 待解决
用户认证功能有哪些?
1163浏览 • 1回复 待解决
HarmonyOS有没有打开系统设置页代码
584浏览 • 1回复 待解决
有没有代码相关文档可以阅读?
3166浏览 • 1回复 待解决
HarmonyOS 有没有类似deeplink功能唤起app
958浏览 • 1回复 待解决