|
目录结构
第一步:
ScrollViewActivity.java
package com.taofu5;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.TextView;
public class ScrollViewActivity extends Activity {
ScrollView scrollView;
String msg = "滚动视图,滚动视图演示滚动视图,滚动视图演示滚动视图";
String str = "";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
scrollView = new ScrollView(this);
TextView tv = new TextView(this);
tv.setTextSize(23);
for(int i=0; i<20; i++) {
str = str + msg;
}
tv.setText(str);
scrollView.addView(tv);
setContentView(scrollView);
}
}
复制代码
第二步
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.taofu5"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ScrollViewActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
复制代码
效果如下:
|
|