Android ScrollView(垂直)含代碼

    Android ScrollView(垂直)

    android.widget.ScrollView類提供了滾動(dòng)視圖的功能。愛(ài)掏網(wǎng) - it200.comScrollView用于在ScrollView內(nèi)滾動(dòng)調(diào)色板的子元素。愛(ài)掏網(wǎng) - it200.comAndroid默認(rèn)支持垂直滾動(dòng)視圖。愛(ài)掏網(wǎng) - it200.com垂直ScrollView垂直滾動(dòng)元素。愛(ài)掏網(wǎng) - it200.com

    Android使用HorizontalScrollView用于水平滾動(dòng)視圖。愛(ài)掏網(wǎng) - it200.com

    讓我們實(shí)現(xiàn)一個(gè)簡(jiǎn)單的垂直ScrollView的例子。愛(ài)掏網(wǎng) - it200.com

    activity_main.xml

    現(xiàn)在,從調(diào)色板中拖動(dòng)ScrollView到activity_main.xml文件中,并在其中放置一些調(diào)色板元素。愛(ài)掏網(wǎng) - it200.com

    文件:activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.test.scrollviews.MainActivity">
    
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="Vertical ScrollView example"
            android:id="@+id/textView"
            android:layout_gravity="center_horizontal"
            android:layout_centerHorizontal="true"
            android:layout_alignParentTop="true" />
    
    
        <ScrollView android:layout_marginTop="30dp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/scrollView">
    
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >
    
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 1" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 2" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 3" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 4" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 5" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 6" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 7" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 8" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 9" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 10" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 11" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 12" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 13" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 14" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 15" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 16" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 17" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 18" />
    
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 19" />
                <Button
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Button 20" />
    
            </LinearLayout>
    
        </ScrollView>
    
    </RelativeLayout>
    

    Activity類

    在Activity類中,我們沒(méi)有更改任何代碼。愛(ài)掏網(wǎng) - it200.com

    文件:MainActivity.java

    package com.example.test.scrollviews;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    }
    

    輸出

    聲明:所有內(nèi)容來(lái)自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。
    發(fā)表評(píng)論
    更多 網(wǎng)友評(píng)論0 條評(píng)論)
    暫無(wú)評(píng)論

    返回頂部

    主站蜘蛛池模板: 午夜爽爽性刺激一区二区视频| 日韩有码一区二区| 交换国产精品视频一区| 福利视频一区二区牛牛| 亚洲综合无码一区二区痴汉| 亚洲一区二区三区影院| 激情啪啪精品一区二区| 成人区人妻精品一区二区三区| 无码人妻精品一区二区三区在线 | 国产精品va一区二区三区| 精品国产伦一区二区三区在线观看| 精品国产不卡一区二区三区| 日本中文字幕在线视频一区| 国产在线一区视频| 国产一区美女视频| 日本美女一区二区三区 | 一区二区三区免费看| 日本一区二区三区精品视频| 日韩精品一区二区三区中文3d| 蜜桃传媒一区二区亚洲AV| 精品国产免费一区二区| 国产在线一区二区三区在线| 国产一区二区三区免费视频| 波多野结衣中文一区二区免费| 日本一区二区三区四区视频| 精品乱人伦一区二区| 一区二区三区四区在线视频| 精品国产亚洲一区二区在线观看| 国产福利电影一区二区三区| 丝袜无码一区二区三区| 国产丝袜美女一区二区三区| 国产精品熟女一区二区| 久久久久人妻一区二区三区vr| 亚洲视频在线一区二区三区| 伊人色综合视频一区二区三区| 影院成人区精品一区二区婷婷丽春院影视 | 99久久精品国产免看国产一区 | 无码国产精品一区二区免费vr | 中文字幕无线码一区2020青青| 亚洲国产AV无码一区二区三区| 春暖花开亚洲性无区一区二区|