The code has been written in three files
a) main.xml
b) strings.xml
b) scrollActivity.java
The code is as follows
a) main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation = "vertical">
<TextView
android:layout_width="fill_parent" android:layout_height="80px" android:background = "@color/RED"/>
<TextView
android:layout_width="fill_parent" android:layout_height="80px" android:background = "@color/DARK_GREEN"/>
<TextView
android:layout_width="fill_parent" android:layout_height="80px" android:background = "@color/LIGHT_BLUE"/>
<TextView
android:layout_width="fill_parent" android:layout_height="80px" android:background = "@color/GREEN"/>
<TextView
android:layout_width="fill_parent" android:layout_height="80px" android:background = "@color/BLUE"/>
<TextView
android:layout_width="fill_parent" android:layout_height="80px" android:background = "@color/LIGHT_RED"/>
<TextView
android:layout_width="fill_parent" android:layout_height="80px" android:background = "@color/NEW_COLOR"/>
</LinearLayout>
</ScrollView>
b) strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, scrollActivity!</string>
<string name="app_name">ScrollViewTest</string>
<color name="RED">#FF5555</color>
<color name="BLUE">#5555FF</color>
<color name="LIGHT_BLUE">#2222AA</color>
<color name="GREEN">#88FF22</color>
<color name="DARK_GREEN">#00FF00</color>
<color name="LIGHT_RED">#FFAAAA</color>
<color name="NEW_COLOR">#FFAAEE</color>
</resources>
c) scrollActivity.java
package org.example.scroll;
import android.app.Activity;
import android.os.Bundle;
public class scrollActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

This comment has been removed by the author.
ReplyDelete