HarmonyOS Swiper组件的分页图标没法设置到底部

​DotIndicator组件。

1.跟底部距离有点大。

2.希望这个距离能让我们自己控制​。

@Entry  
@Component  
struct SwiperDemo {  
  @State message: string = 'Hello World';  
  private swiperController: SwiperController = new SwiperController()  
  build() {  
    RelativeContainer() {  
      Swiper(this.swiperController) {  
        Text('0')  
          .width('90%')  
          .height('100%')  
          .backgroundColor(Color.Gray)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
  
        Text('1')  
          .width('90%')  
          .height('100%')  
          .backgroundColor(Color.Green)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
  
        Text('2')  
          .width('90%')  
          .height('100%')  
          .backgroundColor(Color.Pink)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
      }  
      .loop(true)  
      .indicator( new DotIndicator()  
        .selectedItemWidth('30lpx')  
        .selectedItemHeight('4lpx')  
        .itemWidth('15lpx')  
        .itemHeight('4lpx')  
        .color('rgba(255,255,255,0.40)')  
        .selectedColor('rgba(255,255,255,0.80)')  
        .bottom('0lpx')  
        .mask(true)  
        )  
    }  
    .height('100%')  
    .width('100%')  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
HarmonyOS
2024-10-28 09:45:26
662浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

可参考如下demo自定义分页:

@Entry  
@Component  
export struct SwiperComponent {  
  private swiperController: SwiperController = new SwiperController()  
  @State currentIndex: number = 0;  
  @State swiperData: number[] = [1,2,3];  
  
  build() {  
    Column() {  
      Swiper(this.swiperController) {  
        Text('0')  
          .width('90%')  
          .height('50%')  
          .backgroundColor(Color.Gray)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
        Text('1')  
          .width('90%')  
          .height('50%')  
          .backgroundColor(Color.Green)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
        Text('2')  
          .width('90%')  
          .height('50%')  
          .backgroundColor(Color.Pink)  
          .textAlign(TextAlign.Center)  
          .fontSize(30)  
      }.indicator(false).autoPlay(true).onChange(index => {  
        this.currentIndex = index;  
      })  
  
      Row({ space: 10 }) {  
        ForEach(this.swiperData, (item: number, index: number) => {  
          Shape() {  
            Rect()  
              .width(50)  
              .height(10)  
              .radius(5)  
              .fill(index !== this.currentIndex ? Color.Black : Color.Red)  
              .fillOpacity(0.6)  
          }  
        })  
      }.margin({ top: 12 })  
    }.width('100%')  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
分享
微博
QQ
微信
回复
2024-10-28 15:18:40
相关问题
list组件无法滚动到底部
2291浏览 • 1回复 待解决
HarmonyOS 分页功能组件
621浏览 • 1回复 待解决
Swiper组件如何设置导航点位置
3539浏览 • 1回复 待解决
Swiper组件设置不跟随手势滑动
1411浏览 • 1回复 待解决
HarmonyOS APP在设置图标如何设置
504浏览 • 1回复 待解决