代码拉取完成,页面将自动刷新
ScrollView是一种带滚动功能的组件,它采用滑动的方式在有限的区域内显示更多的内容
ScrollView的共有XML属性继承自:[StackLayout](../[05]Java UI 布局/[06]StackLayout堆叠布局.md)
ScrollView的自有XML属性见下表:
属性名称 | 中文描述 | 取值 | 取值说明 | 使用案例 |
---|---|---|---|---|
match_viewport | 是否拉伸匹配 | boolean类型 | 可以直接设置true/false,也可以引用boolean资源。 | ohos:match_viewport="true"ohos:match_viewport="$boolean:true" |
rebound_effect | 回弹效果 | boolean类型 | 可以直接设置true/false,也可以引用boolean资源。 | ohos:rebound_effect="true"ohos:rebound_effect="$boolean:true" |
图片
xml部分
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:alignment="center"
ohos:orientation="vertical">
<!-- 文字示例 -->
<ScrollView
ohos:height="match_content"
ohos:width="match_content"
ohos:padding="20vp"
ohos:rebound_effect="true"
>
<Text
ohos:height="match_content"
ohos:width="match_content"
ohos:multiple_lines="true"
ohos:text="$string:ren_ming_ru_cao_jian"
ohos:text_size="20fp"
/>
</ScrollView>
</DirectionalLayout>
图片
xml部分
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:alignment="center"
ohos:orientation="vertical">
<!-- 图片示例 -->
<ScrollView
ohos:height="match_content"
ohos:width="match_content"
ohos:rebound_effect="true"
>
<!-- ohos:visibility="hide">-->
<DirectionalLayout
ohos:height="match_content"
ohos:width="match_content"
ohos:alignment="vertical_center"
ohos:orientation="vertical">
<Image
ohos:height="280vp"
ohos:width="280vp"
ohos:background_element="#f3d"
ohos:image_src="$media:1"
ohos:margin="10vp"
ohos:padding="5vp"/>
<Image
ohos:height="280vp"
ohos:width="280vp"
ohos:background_element="#f3d"
ohos:image_src="$media:1"
ohos:margin="10vp"
ohos:padding="5vp"/>
<Image
ohos:height="280vp"
ohos:width="280vp"
ohos:background_element="#f3d"
ohos:image_src="$media:1"
ohos:margin="10vp"
ohos:padding="5vp"/>
<Image
ohos:height="280vp"
ohos:width="280vp"
ohos:background_element="#f3d"
ohos:image_src="$media:1"
ohos:margin="10vp"
ohos:padding="5vp"/>
</DirectionalLayout>
</ScrollView>
</DirectionalLayout>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。