91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Android組件ScrollView怎么使用

發布時間:2022-04-01 10:27:54 來源:億速云 閱讀:168 作者:iii 欄目:開發技術

今天小編給大家分享一下Android組件ScrollView怎么使用的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

概述

    ScrollView也是一個容器,它是FrameLayout的子類,它的主要作用就是將超出物理屏幕的內容顯示出來,(就是滾動條效果)ScrollView提供垂直滾動,進而可將超出物理屏幕的內容顯示出來。

      在一般情況下,可以將一個采用垂直方式布局組件的LinearLayout作為ScrollLayout容器的子組件,同時,在LinearLayout容器中可以顯示超出屏幕物理高度的內容。

練習

這么說有點抽象,然后我們現在實現完成一個調試板顏色的顯示,效果如下:(可以往下滾動)

代碼:

<?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">
 
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#07C2FB" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#07C2FB" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#C60426FD" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#C60426FD" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#032898" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#032898" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#021173" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#021173" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#504DAE" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#504DAE" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#3C60A6" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#3C60A6" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#282EA8" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#282EA8" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#273523" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="##5E7559" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#0E1E73" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#0E1E73" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#305BC8" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#305BC8" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#282EA8" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#282EA8" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#0B685E" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#0B685E" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#263B7E" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#263B7E" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <View
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#0A7AC5" />
            <TextView
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#0A7AC5" />
        </LinearLayout>
 
    </LinearLayout>
 
</ScrollView>

Android組件ScrollView怎么使用

      當然了ScrollView只提供了垂直滾動條,若要使用水平滾動功能,則Android提供了HorizontalScrollView容器,HorizontalScrollView容器可以提供水平滾動,它的使用方法與ScrollView類似

HorizontalScrollView:

<?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">
 
 
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="horizontal">
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#2479CE" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#2479CE" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#C97A06" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#C97A06" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#68060E" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#68060E" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#271904" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#271904" />
        </LinearLayout>
 
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#673AB7" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#673AB7" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#1B5834" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#1B5834" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#680379" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#680379" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#043485" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#043485" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#798506" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#798506" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#B12E04" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#B12E04" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#A09006" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#A09006" />
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <View
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="2"
                android:background="#920C02" />
 
            <TextView
                android:layout_width="200px"
                android:layout_height="60dp"
                android:layout_weight="1"
                android:gravity="center"
                android:text="#920C02" />
        </LinearLayout>
 
 
    </LinearLayout>
 
</HorizontalScrollView>

 實現效果:

Android組件ScrollView怎么使用

以上就是“Android組件ScrollView怎么使用”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

高邮市| 北碚区| 陵川县| 台南市| 绥滨县| 巴林左旗| 阿拉善右旗| 靖安县| 六安市| 友谊县| 玛沁县| 利津县| 元氏县| 灵宝市| 延吉市| 兴城市| 资兴市| 黎城县| 屯昌县| 龙山县| 揭阳市| 米林县| 临城县| 苍梧县| 南溪县| 百色市| 东明县| 小金县| 禹城市| 旌德县| 呼和浩特市| 安阳市| 安义县| 都昌县| 昆山市| 贡山| 赤水市| 宁波市| 静海县| 来宾市| 灯塔市|