android 中ScrollView的使用

android中布局一般都有两种方式,一种xml声明,另外一种则是程序声明:

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
  
    <ScrollView 
        android:id="@+id/Scroll"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <TextView 
            android:id="@+id/txt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
    </ScrollView>
     


</LinearLayout>


手动代码声明:

TextView txt=new TextView(this);
        txt.setText(str);
        ScrollView scrollView = new ScrollView(this);
        scrollView.addView(txt);
        setContentView(scrollView);

 

 

posted @ 2012-05-11 14:36  shyscool  阅读(358)  评论(0编辑  收藏  举报