Android学习笔记之ScrollView

Android学习笔记之ScrollView_第1张图片Android学习笔记之ScrollView_第2张图片

 

<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

                

你可能感兴趣的:(android,api,layout,Class,encoding)