Android HorizontalScrollView含代碼

Android HorizontalScrollView

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

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

讓我們來實現(xiàn)一個簡單的 HorizontalScrollView 的例子。愛掏網(wǎng) - it200.com

activity_main.xml

現(xiàn)在,從工具欄中拖動一個HorizontalScrollView到activity_main.xml文件中,并在其中放置一些視圖或元素。愛掏網(wǎng) - 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類

這是自動生成的代碼,我們沒有在這里編寫任何代碼。愛掏網(wǎng) - 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);
    }
}

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

返回頂部

主站蜘蛛池模板: 欧美性色黄大片www| 亚洲视频一区网站| 亚洲综合天堂网| 久久夜色精品国产亚洲| 国产一区二区三区乱码网站| 欧美亚洲综合在线| 国产精品久久久久9999| 四虎国产精品永久免费网址| 久久亚洲国产成人精品无码区| 91抖音在线观看| 精品国产免费观看| 日韩免费在线视频| 国产嘿嘿嘿视频在线观看| 亚洲欧美另类视频| 2020国产精品自拍| 男人添女人30分钟免费| 奇米在线777| 国产亚洲精品美女久久久| 久久九九国产精品怡红院| 蜜桃臀无码内射一区二区三区| 日本www在线| 国产步兵社区视频在线观看| 乱了嗯祖宗啊用力| 2019av在线视频| 樱桃视频影院在线播放| 国产麻豆精品原创| 亚洲护士毛茸茸| 99re热久久资源最新获取| 精品无人乱码一区二区三区| 日本道v高清免费| 国产gay小鲜肉| www.九色视频| 欧美日韩国产高清一区二区三区| 天堂网www资源在线| 午夜影视免费完整高清在线观看网站 | 能播放18xxx18女同| 成人免费一区二区三区| 人禽伦免费交视频播放| 18pao国产成视频永久免费| 日韩电影免费在线观看网站| 四虎精品1515hh|