Android HorizontalScrollView含代碼

    Android HorizontalScrollView

    一個 HorizontalScrollView 是一個FrameLayout。愛掏網 - it200.com android.widget.HorizontalScrollView 類提供了水平滾動視圖的功能。愛掏網 - it200.comHorizontalScrollView用于以水平方向滾動子元素或視圖。愛掏網 - it200.comHorizontalScrollView只支持水平滾動。愛掏網 - it200.com

    在垂直滾動方面,Android使用ScrollView。愛掏網 - it200.com

    讓我們來實現一個簡單的 HorizontalScrollView 的例子。愛掏網 - it200.com

    activity_main.xml

    現在,從工具欄中拖動一個HorizontalScrollView到activity_main.xml文件中,并在其中放置一些視圖或元素。愛掏網 - it200.com

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Horizontal ScrollView Example"
            android:id="@+id/textView"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true" />
    
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="25dp">
            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:id="@+id/horizontalScrollView">
    
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button1"
                        android:id="@+id/button1" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button2"
                        android:id="@+id/button2" />
    
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button3"
                        android:id="@+id/button3" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button4"
                        android:id="@+id/button4" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button5"
                        android:id="@+id/button5" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button6"
                        android:id="@+id/button6" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button7"
                        android:id="@+id/button7" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New Button8"
                        android:id="@+id/button8"/>
                </LinearLayout>
    
            </HorizontalScrollView>
        </LinearLayout>
    </RelativeLayout>
    

    Activity類

    這是自動生成的代碼,我們沒有在這里編寫任何代碼。愛掏網 - it200.com

    文件:MainActivity.java

    package com.example.test.horizantalscrollview;
    
    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);
        }
    }
    

    聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。
    發表評論
    更多 網友評論0 條評論)
    暫無評論

    返回頂部

    主站蜘蛛池模板: 国产精品自在拍一区二区不卡| 国产午夜三级一区二区三| 人妻免费一区二区三区最新 | 欧美激情国产精品视频一区二区 | 亚洲福利视频一区二区| 无码国产精品一区二区免费式直播 | 一夲道无码人妻精品一区二区| 亚洲一区二区三区写真 | 国产精品香蕉一区二区三区| 精品国产AⅤ一区二区三区4区| 亚洲一区无码中文字幕乱码| av无码人妻一区二区三区牛牛| 国产精品成人一区二区三区| 男插女高潮一区二区| 97久久精品一区二区三区| 亚洲av午夜福利精品一区| 久久精品一区二区三区中文字幕| 欧洲亚洲综合一区二区三区| 精品人无码一区二区三区| 色窝窝无码一区二区三区色欲 | 亚洲熟女一区二区三区| 国产精品免费一区二区三区 | 精品女同一区二区三区在线 | 春暖花开亚洲性无区一区二区 | 日本不卡一区二区三区视频| 中日韩精品无码一区二区三区| 最美女人体内射精一区二区| 影院无码人妻精品一区二区| 国产一区二区在线观看| 日韩精品无码一区二区三区| 黄桃AV无码免费一区二区三区| 午夜视频在线观看一区二区 | 国内精品视频一区二区三区| 麻豆精品久久久一区二区| 亚洲美女高清一区二区三区 | 色综合视频一区二区三区| 久久青青草原一区二区| 无码人妻久久一区二区三区| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 国产在线步兵一区二区三区| 中文字幕一区一区三区|