Android垂直滚动控件ScrollView使用方法详解

 更新时间:2017年08月10日 08:55:11   作者:饭饭_fan  
这篇文章主要为大家详细介绍了Android垂直滚动控件ScrollView的使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

一、简介

二、方法

1)ScrollView垂直滚动控件使用方法

1、在layout布局文件的最外层建立一个ScrollView控件

2、在ScrollView控件中加入一个LinearLayout控件,并且把它的orientation设置为vertical

3、在LinearLayout控件中放入多个装有图片的ImageView控件

三、代码实例

1、效果图

2、代码

/Ex27ScrollView/src/fry/Activity01.java

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:scrollbars="none"
 >
 <LinearLayout 
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  >
  <ImageView 
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/item1"
   />
  <ImageView 
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/item2"
   />
  <ImageView 
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/item3"
   />
  <ImageView 
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/item4"
   />
  <ImageView 
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/item5"
   />
 </LinearLayout>
 

</ScrollView>

四、注意点

1、ScrollView控件是放在layout的最外层

2、ScrollView控件中控制进度条的属性android:scrollbars

android:scrollbars="none"

是将滚动条设置为没有

 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • flutter实现页面多个webview的方案详解

    flutter实现页面多个webview的方案详解

    这篇文章主要为大家详细介绍了flutter如何实现页面多个webview的效果,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起了解下
    2023-09-09
  • Kotlin Job启动流程源码层深入分析

    Kotlin Job启动流程源码层深入分析

    如果要我拿现实中的一事物与Kotlin协程中的Job做一个类比,那么我会把Job比作成海洋中的冰山。自由漂浮的冰山约有90%体积沉在海水表面下,因此看着浮在水面上的形状并猜不出水下的形状
    2022-11-11
  • Android基础之使用Fragment控制切换多个页面

    Android基础之使用Fragment控制切换多个页面

    Android官方已经提供了Fragment的各种使用的Demo例子,在我们SDK下面的API Demo里面就包含了Fragment的各种使用例子,需要看Demo的朋友,直接看API Demo那个程序就可以了,不用到处去找。里面分开不同功能,实现了不同的类
    2013-07-07
  • Android动态替换Application实现

    Android动态替换Application实现

    这篇文章主要介绍了Android动态替换Application实现,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-05-05
  • Android入门之Style与Theme用法实例解析

    Android入门之Style与Theme用法实例解析

    这篇文章主要介绍了Android入门之Style与Theme用法,非常实用的功能,需要的朋友可以参考下
    2014-08-08
  • Android解析Intent Filter的方法

    Android解析Intent Filter的方法

    这篇文章主要介绍了Android解析Intent Filter的方法,较为详细的分析了Intent解析的原理与相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-07-07
  • Android PopupWindow实现微信右上角的弹出菜单

    Android PopupWindow实现微信右上角的弹出菜单

    这篇文章主要为大家详细介绍了Android PopupWindow实现微信右上角的弹出菜单,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-04-04
  • Android Compose实现伸缩ToolBar的思路详解

    Android Compose实现伸缩ToolBar的思路详解

    这篇文章主要介绍了Android Compose之伸缩ToolBar的实现,本文给大家分享主要实现思路及实现过程,通过实例代码给大家介绍的非常详细,需要的朋友可以参考下
    2021-10-10
  • Flutter使用SingleTickerProviderStateMixin报错解决

    Flutter使用SingleTickerProviderStateMixin报错解决

    这篇文章主要为大家介绍了Flutter使用SingleTickerProviderStateMixin报错解决示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-08-08
  • 去掉ListView底部的ListDivider的方法

    去掉ListView底部的ListDivider的方法

    下面小编就为大家带来一篇去掉ListView底部的ListDivider的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-04-04

最新评论