当前位置: 代码迷 >> Android >> Android的ScrollView跟HorizontalScrollView-android学习之旅(四十一)
  详细解决方案

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

热度:90   发布时间:2016-04-28 00:34:42.0
Android的ScrollView和HorizontalScrollView-android学习之旅(四十一)

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>

效果图

这里写图片描述

  相关解决方案