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

  

<强>一、简介

  

用法ScrollView大致相同

  

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

  

<强>二、方法

  

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

  

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

  

2,在HorizontalScrollView控件中加入一个LinearLayout控件,并且把它的方向设置为水平

  

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

  

2) HorizontalScrollView和ScrollView混合使用方法

  

,以先垂直后水平为例

  

1,在布局布局文件的最外层建立一个滚动视图控件

  

2,在滚动视图控件中加入一个LinearLayout控件,并且把它的方向设置为垂直

  

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

  

<强>三、代码实例

  

HorizontalScrollView水平滚动控件使用方法

  

1,水平滚动效果图:

  

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

  

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

  

2,水平滚动代码:

  

/Ex27ScrollView/res/布局/activity02.xml

  

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; HorizontalScrollView xmlns: android=" http://schemas.android.com/apk/res/android "   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android:滚动条="没有"   比;   LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" match_parent "   面向android:="水平"   比;   & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item1 "/比;   & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable/第二条”/比;   & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item3 "/比;   & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item4 "/比;   & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item5 "/比;   & lt;/LinearLayout>         & lt;/HorizontalScrollView>   之前      

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

  

 HorizontalScrollView水平滚动控件使用方法详解“> <img src=

  

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

  

/Ex27ScrollView/res/布局/activity03.xml

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; ScrollView xmlns: android=" http://schemas.android.com/apk/res/android "   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android:滚动条="没有"比;      LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" match_parent "   面向android:=按怪薄北?      & lt; HorizontalScrollView   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android:滚动条="没有"比;      LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" match_parent "   面向android:="水平"比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item1 "/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable/第二条”/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item3 "/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item4 "/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item5 "/比;   & lt;/LinearLayout>   & lt;/HorizontalScrollView>   & lt; HorizontalScrollView   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android:滚动条="没有"比;      LinearLayout & lt;   android: layout_width=" match_parent "   android: layout_height=" match_parent "   面向android:="水平"比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item1 "/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable/第二条”/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item3 "/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item4 "/比;      & lt; ImageView   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: src=" https://www.yisu.com/zixun/@drawable item5 "/比;   & lt;/LinearLayout>   & lt;/HorizontalScrollView>   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

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