Android Tutorials - Herong's Tutorial Examples - v3.05, by Herong Yang
android.widget.ScrollView Class - Scrolling Text View
This section provides tutorial example on how to create a scrollable screen to view large contents of text using the android.widget.ScrollView Class.
According the Android reference document, "The TextView class also takes care of its own scrolling, so does not require a ScrollView, but using the two together is possible to achieve the effect of a text view within a larger container." But I don't know how to make TextView object to become scrollable. So I places the TextView object inside a ScrollView object to make it work.
1. Enhance my application to make the screen scrollable by editing .\src\com\herongyang\AboutAndroid.java
/* AboutAndroid.java * Version 3.0 - Making the screen scrollable * Copyright (c) 2015, HerongYang.com, All Rights Reserved. */ package com.herongyang; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.ScrollView; public class AboutAndroid extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String msg = ""; msg += "System properties\n"; msg += "-------------\n"; java.util.Properties props = System.getProperties(); java.util.Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String k = (String) e.nextElement(); String v = props.getProperty(k); msg += k+": "+v+"\n"; } TextView tv = new TextView(this); tv.setText(msg); ScrollView sv = new ScrollView(this); sv.addView(tv); setContentView(sv); } }
2. Uninstall the previous version, build, install and run this new version. Some system properties are displayed:
Very nice. I can scroll down to see all system properties now!
After reviewing the output, I see several interesting system properties on my Android emulator:
java.home: /system java.vm.name: Dalvik java.vm.version: 2.1.0 java.vm.vendor: The Android Project java.runtime.name: Android Runtime os.name: Linux os.version: 3.4.67-01422-gd3ffcc7-dirty
Below was some system properties I got from my Android 4.0.3 emulator created with Android SDK R17:
java.home: /system java.vm.name: Dalvik java.vm.version: 1.6.0 java.vm.vendor: The Android Project java.runtime.name: Android Runtime os.name: Linux os.version: 2.6.29-g46b05b2 os.arch.armv71
Table of Contents
Installing JDK 1.8 on Windows System
Installation of Android SDK R24 and Emulator
Installing Apache Ant 1.9 on Windows System
Developing First Android Application - HelloAndroid
Android Application Package (APK) Files
Android Debug Bridge (adb) Tool
►AboutAndroid - Application to Retrieve System Information
java.lang.System Class - Accessing System Information
Creating Android Project for Simple Application
Build, Install and Run Android Application
System.getProperties() - Retrieving System Properties
►android.widget.ScrollView Class - Scrolling Text View
System.getenv() Method - System Environment Variables
android.os.Environment Class - Environment Folders
android.content.Context - Application Context Information
android.app.Activity Class and Activity Lifecycle
View Objects and Layout Resource Files
Using "adb logcat" Command for Debugging
Build Process and Package File Content
Samsung Galaxy Tab 3 Mini Tablet
USB Debugging Applications on Samsung Tablet
USB Debugging Applications on LG-V905R Tablet