国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

HorizontalScrollView水平滾動控件使用方法詳解

2019-10-22 18:30:14
字體:
來源:轉載
供稿:網友

一、簡介

用法ScrollView大致相同

HorizontalScrollView,水平滾動控件

二、方法

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、水平滾動效果圖:

HorizontalScrollView,水平滾動控件

HorizontalScrollView,水平滾動控件

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、水平豎直混合滾動效果圖

HorizontalScrollView,水平滾動控件HorizontalScrollView,水平滾動控件

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,保證了這個,怎么用也不會錯

 以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兰州市| 天等县| 文山县| 城步| 荣昌县| 平定县| 中方县| 高平市| 休宁县| 麻栗坡县| 大同县| 博客| 大关县| 沂源县| 中江县| 游戏| 社会| 云阳县| 安新县| 安龙县| 通渭县| 馆陶县| 达孜县| 昭觉县| 县级市| 昌乐县| 松滋市| 会昌县| 南漳县| 武城县| 汽车| 松江区| 沂源县| 惠水县| 垣曲县| 永川市| 漯河市| 宽甸| 长阳| 周口市| 岳阳县|