全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

HorizontalScrollView水平滚动控件使用方法详解

一、简介

用法ScrollView大致相同

二、方法

1)HorizontalScrollView水平滚动控件使用方法

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

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

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

2)HorizontalScrollView和ScrollView混合使用方法

 以先垂直后水平为例

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

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

3、在这个LinearLayout中添加多个已经弄好的HorizontalScrollView水平滚动控件 

三、代码实例

HorizontalScrollView水平滚动控件使用方法

1、水平滚动效果图:

2、水平滚动代码:

/Ex27ScrollView/res/layout/activity02.xml

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView 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="horizontal"
    >
    <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>
  

</HorizontalScrollView>

3、水平竖直混合滚动效果图

3、水平竖直混合滚动效果代码

/Ex27ScrollView/res/layout/activity03.xml

<?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" >

    <HorizontalScrollView
      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="horizontal" >

        <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>
    </HorizontalScrollView>
    <HorizontalScrollView
      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="horizontal" >

        <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>
    </HorizontalScrollView>
    <HorizontalScrollView
      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="horizontal" >

        <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>
    </HorizontalScrollView>
    <HorizontalScrollView
      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="horizontal" >

        <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>
    </HorizontalScrollView>
    <HorizontalScrollView
      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="horizontal" >

        <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>
    </HorizontalScrollView>
  </LinearLayout>

</ScrollView>

四、注意点

 1、始终注意HorizontalScrollView和ScrollView的直接儿子只有一个,一般都是LinearOut,保证了这个,怎么用也不会错

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


# HorizontalScrollView  # 水平滚动控件  # Android自定义HorizontalScrollView实现qq侧滑菜单  # Android HorizontalScrollView左右滑动效果  # Android UI系列-----ScrollView和HorizontalScrollView的详  # Android HorizontalScrollView内子控件横向拖拽实例代码  # Android利用HorizontalScrollView仿ViewPager设计简单相册  # Android自定义HorizontalScrollView打造超强Gallery效果  # Android中HorizontalScrollView使用方法详解  # Android使用自定义控件HorizontalScrollView打造史上最简单的侧滑菜单  # Android中实现多行、水平滚动的分页的Gridview实例源码  # android listview 水平滚动和垂直滚动的小例子  # 多个  # 建立一个  # 设置为  # 都是  # 最外层  # 在这个  # 只有一个  # 为例  # 弄好  # 大家多多  # pre  # text  # style  # Ex27ScrollView  # class  # res  # center  # align  # xml  # layout 


相关文章: 教育培训网站制作流程,请问edu教育网站的域名怎么申请?  如何快速生成可下载的建站源码工具?  Swift中switch语句区间和元组模式匹配  广州营销型建站服务商推荐:技术优势与SEO优化解析  宝华建站服务条款解析:五站合一功能与SEO优化设置指南  深圳 网站制作,深圳招聘网站哪个比较好一点啊?  韩国网站服务器搭建指南:VPS选购、域名解析与DNS配置推荐  如何零基础开发自助建站系统?完整教程解析  北京企业网站设计制作公司,北京铁路集团官方网站?  建站之星如何优化SEO以实现高效排名?  如何快速搭建高效服务器建站系统?  网站规划与制作是什么,电子商务网站系统规划的内容及步骤是什么?  哈尔滨网站建设策划,哈尔滨电工证查询网站?  网站制作多少钱一个,建一个论坛网站大约需要多少钱?  已有域名和空间如何快速搭建网站?  如何在阿里云通过域名搭建网站?  完全自定义免费建站平台:主题模板在线生成一站式服务  大连网站设计制作招聘信息,大连投诉网站有哪些?  如何通过万网虚拟主机快速搭建网站?  专业的网站制作设计是什么,如何制作一个企业网站,建设网站的基本步骤有哪些?  建站之星3.0如何解决常见操作问题?  家族网站制作贴纸教程视频,用豆子做粘帖画怎么制作?  如何设计高效校园网站?  定制建站平台哪家好?企业官网搭建与快速建站方案推荐  如何配置IIS站点权限与局域网访问?  如何配置FTP站点权限与安全设置?  如何将凡科建站内容保存为本地文件?  制作假网页,招聘网的薪资待遇,会有靠谱的吗?一面试又各种折扣?  装修招标网站设计制作流程,装修招标流程?  大连 网站制作,大连天途有线官网?  南平网站制作公司,2025年南平市事业单位报名时间?  建站主机CVM配置优化、SEO策略与性能提升指南  网站企业制作流程,用什么语言做企业网站比较好?  如何用PHP快速搭建CMS系统?  免费的流程图制作网站有哪些,2025年教师初级职称申报网上流程?  如何在橙子建站中快速调整背景颜色?  php8.4新语法match怎么用_php8.4match表达式替代switch【方法】  香港服务器网站卡顿?如何解决网络延迟与负载问题?  如何快速搭建自助建站会员专属系统?  已有域名和空间,如何快速搭建网站?  如何做静态网页,sublimetext3.0制作静态网页?  建站主机是否属于云主机类型?  高端企业智能建站程序:SEO优化与响应式模板定制开发  宝塔面板创建网站无法访问?如何快速排查修复?  上海网站制作网站建设公司,建筑电工证网上查询系统入口?  建站之星好吗?新手能否轻松上手建站?  全景视频制作网站有哪些,全景图怎么做成网页?  音乐网站服务器如何优化API响应速度?  微信网站制作公司有哪些,民生银行办理公司开户怎么在微信网页上查询进度?  建站之星在线版空间:自助建站+智能模板一键生成方案 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。