0

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

4

1 回答 1

0

在 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>

有关详细信息,请参阅Java UI 的 scrollView

于 2021-07-28T09:52:08.707 回答