Android学习笔记之ScrollView

 

<1>简介

 一种可供用户滚动的层次结构布局容器,允许显示比实际多的内容。ScrollView是一种FrameLayout,意味需要在其上放置有自己滚动内容的子元素。子元素可以是一个复杂的对象的布局管理器。通常用的子元素是垂直方向的LinearLayout,显示在最上层的垂直方向可以让用户滚动的箭头。

  TextView类也有自己的滚动功能,所以不需要使用ScrollView,但是只有两个结合使用,才能保证显示较多内容时候的效率。但只有两者结合使用才可以实现在一个较大的容器中一个文本视图效果。

  ScrollView只支持垂直方向的滚动。

package xiaosi.scrollView;

import android.app.Activity;
import android.os.Bundle;

public class ScrollViewActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}


 

main.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="@+id/ScrollView01" 
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content" 
	xmlns:android="http://schemas.android.com/apk/res/android"> 
	<TableLayout 
	    android:layout_width="wrap_content" 
	    android:layout_height="wrap_content" >
	   <TableRow 
	       android:layout_width="fill_parent" 
	       android:layout_height="wrap_content"> 
	       <ImageView 
	           android:layout_width="fill_parent"
	           android:layout_height="wrap_content"
	           android:scaleType="fitXY"
	           android:src="@drawable/d"/>
	   </TableRow> 
	   
	   <TableRow 
	       android:layout_width="fill_parent" 
	       android:layout_height="wrap_content"> 
	       <ImageView 
	           android:layout_width="fill_parent"
	           android:layout_height="wrap_content"
	           android:scaleType="fitXY"
	           android:src="@drawable/f"/>
	   </TableRow> 
	   
	   
	   <TableRow 
	       android:layout_width="fill_parent" 
	       android:layout_height="wrap_content"> 
	       <ImageView 
	           android:layout_width="fill_parent"
	           android:layout_height="wrap_content"
	           android:scaleType="fitXY"
	           android:src="@drawable/g"/>
	   </TableRow> 
	   
	   <TableRow 
	       android:layout_width="fill_parent" 
	       android:layout_height="wrap_content"> 
	       <ImageView 
	           android:layout_width="fill_parent"
	           android:layout_height="wrap_content"
	           android:scaleType="fitXY"
	           android:src="@drawable/h"/>
	   </TableRow> 
	</TableLayout>
</ScrollView>

 

源代码下载:点击下载

 


友情连接:ScrollView  API

                 Android 中文 API (100) —— ScrollView

                

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值