Android的ScrollView和HorizontalScrollView-android学习之旅(四十一)

来源:互联网 发布:腾讯视频数据分析 编辑:程序博客网 时间:2024/06/03 09:24

HorizontalScrollView和ScrollView简介

ScrollView和HorizontalScrollView都继承于FrameLayout组件,两个都是容器,前者为里面的组件添加竖直的滚动条,后者是水平的滚动条。

代码示例

<?xml version="1.0" encoding="utf-8"?><LinearLayout 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"    >    <ScrollView        android:layout_width="fill_parent"        android:layout_height="fill_parent">        <HorizontalScrollView            android:layout_width="fill_parent"            android:layout_height="fill_parent">            <LinearLayout                android:layout_width="fill_parent"                android:layout_height="wrap_content"                android:orientation="vertical">                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                <TextView                    android:layout_width="fill_parent"                    android:layout_height="wrap_content"                    android:text="hehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"                    android:textSize="60dp"/>                </LinearLayout>            </HorizontalScrollView>        </ScrollView></LinearLayout>

效果图

这里写图片描述

0 0
原创粉丝点击