【问题标题】:How to automatically slide the pages in page slider HarmonyOS?如何在页面滑块 HarmonyOS 中自动滑动页面?
【发布时间】:2021-08-19 17:29:01
【问题描述】:

我在 HarmonyOS 中实现了一个受ArcPageIndicator 启发的自定义页面滑块指示器,并测试我想使用页面滑块自动滑动页面。如何在 HarmonyOS 中做到这一点?

【问题讨论】:

    标签: java android huawei-mobile-services huawei-developers harmonyos


    【解决方案1】:

    在layout目录下的XML文件中创建一个ScrollView组件。 ScrollView 需要布局的支持。下面以DirectionalLayout为例。

    <ScrollView
        ohos:id="$+id:scrollview"
        ohos:height="300vp"
        ohos:width="300vp"
        ohos:background_element="#FFDEAD"
        ohos:top_margin="32vp"
        ohos:bottom_padding="16vp"
        ohos:layout_alignment="horizontal_center">
        <DirectionalLayout
            ohos:height="match_content"
            ohos:width="match_content">
            <!-- $media:plant: image resource referenced in the media directory-->
            <Image
                ohos:width="300vp"
                ohos:height="match_content"
                ohos:top_margin="16vp"
                ohos:image_src="$media:plant"/>
            <!-- Add content to be displayed -->
            ...
        </DirectionalLayout>
    </ScrollView>
    

    更多详情请见scrollView of the Java UI

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 2020-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多