January 2013
Intermediate to advanced
408 pages
9h 23m
English
A ScrollView is a special type of FrameLayout in that it enables users to scroll through a list of views that occupy more space than the physical display provides. The ScrollView can contain only one child view or ViewGroup, which normally is a LinearLayout. This recipe shows how to use the ScrollView.
Assume you have the following code snippet in the activity_main.xml file:
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button 1" /> <Button android:id="@+id/button2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button 2" /> <Button android:id="@+id/button3" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button 3" /> <EditText android:id="@+id/txt" android:layout_width="match_parent" android:layout_height="600px" /> <Button android:id="@+id/button4" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button 4" /> <Button android:id="@+id/button5" android:layout_width="match_parent" ...Read now
Unlock full access