HorizontalScrollView水平滾動(dòng)控件使用方法詳解
一、簡(jiǎn)介
用法ScrollView大致相同
二、方法
1)HorizontalScrollView水平滾動(dòng)控件使用方法
1、在layout布局文件的最外層建立一個(gè)HorizontalScrollView控件
2、在HorizontalScrollView控件中加入一個(gè)LinearLayout控件,并且把它的orientation設(shè)置為horizontal
3、在LinearLayout控件中放入多個(gè)裝有圖片的ImageView控件
2)HorizontalScrollView和ScrollView混合使用方法
以先垂直后水平為例
1、在layout布局文件的最外層建立一個(gè)ScrollView控件
2、在ScrollView控件中加入一個(gè)LinearLayout控件,并且把它的orientation設(shè)置為vertical
3、在這個(gè)LinearLayout中添加多個(gè)已經(jīng)弄好的HorizontalScrollView水平滾動(dòng)控件
三、代碼實(shí)例
HorizontalScrollView水平滾動(dòng)控件使用方法
1、水平滾動(dòng)效果圖:
2、水平滾動(dòng)代碼:
/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、水平豎直混合滾動(dòng)效果圖
3、水平豎直混合滾動(dòng)效果代碼
/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>
四、注意點(diǎn)
1、始終注意HorizontalScrollView和ScrollView的直接兒子只有一個(gè),一般都是LinearOut,保證了這個(gè),怎么用也不會(huì)錯(cuò)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android自定義HorizontalScrollView實(shí)現(xiàn)qq側(cè)滑菜單
- Android HorizontalScrollView左右滑動(dòng)效果
- Android UI系列-----ScrollView和HorizontalScrollView的詳解
- Android HorizontalScrollView內(nèi)子控件橫向拖拽實(shí)例代碼
- Android利用HorizontalScrollView仿ViewPager設(shè)計(jì)簡(jiǎn)單相冊(cè)
- Android自定義HorizontalScrollView打造超強(qiáng)Gallery效果
- Android中HorizontalScrollView使用方法詳解
- Android使用自定義控件HorizontalScrollView打造史上最簡(jiǎn)單的側(cè)滑菜單
- Android中實(shí)現(xiàn)多行、水平滾動(dòng)的分頁(yè)的Gridview實(shí)例源碼
- android listview 水平滾動(dòng)和垂直滾動(dòng)的小例子
相關(guān)文章
詳解Android的Splash啟動(dòng)圖的兩種動(dòng)態(tài)切換方式
本篇文章主要介紹了詳解Android的Splash啟動(dòng)圖的兩種動(dòng)態(tài)切換方式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06Android?內(nèi)存優(yōu)化知識(shí)點(diǎn)梳理總結(jié)
這篇文章主要介紹了Android?內(nèi)存優(yōu)化知識(shí)點(diǎn)梳理總結(jié),Android?操作系統(tǒng)給每個(gè)進(jìn)程都會(huì)分配指定額度的內(nèi)存空間,App?使用內(nèi)存來(lái)進(jìn)行快速的文件訪問(wèn)交互,長(zhǎng)時(shí)間如此便需要優(yōu)化策略,文章分享優(yōu)化知識(shí)點(diǎn)總結(jié),需要的朋友可以參考一下2022-06-06Android RecyclerView實(shí)現(xiàn)點(diǎn)擊條目刪除
這篇文章主要為大家詳細(xì)介紹了Android RecyclerView實(shí)現(xiàn)點(diǎn)擊條目刪除,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11android實(shí)現(xiàn)將位置信息寫(xiě)入JPEG圖片文件
下面小編就為大家?guī)?lái)一篇android實(shí)現(xiàn)將位置信息寫(xiě)入JPEG圖片文件。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-03-03Android使用OKHTTP解析JSON數(shù)據(jù)的實(shí)例代碼
本篇文章主要介紹了Android使用OKHTTP解析JSON數(shù)據(jù)的實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Android 接收微信、QQ其他應(yīng)用打開(kāi)第三方分享功能
這篇文章主要介紹了Android 接收微信、QQ其他應(yīng)用打開(kāi),第三方分享 ,思路很簡(jiǎn)單通過(guò)在AndroidManifest.xml注冊(cè)ACTION事件,在用于接收分享的Activity里面加接收代碼,感興趣的朋友可以一起學(xué)習(xí)下2022-11-11