Scroll view supports only one child as in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a Linear Layout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.
> Scroll View supports only vertical scrolling.
> In ScrollView they cant support Listview placed as child.
See the Example:
<?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="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 1st Text"
android:textSize="12dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 2nd Text"
android:textSize="14dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 3rd Text"
android:textSize="16dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 4th Text"
android:textSize="18dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 5th Text"
android:textSize="20dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 6th Text"
android:textSize="22dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 7th Text"
android:textSize="24dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 8th Text"
android:textSize="26dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 9th Text"
android:textSize="28dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 10th Text"
android:textSize="30dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 11th Text"
android:textSize="32dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 12th Text"
android:textSize="34dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 13th Text"
android:textSize="36dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 14th Text"
android:textSize="38dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 15th Text"
android:textSize="40dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 16th Text"
android:textSize="42dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 17th Text"
android:textSize="44dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 18th Text"
android:textSize="46dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 19th Text"
android:textSize="20dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 20th Text"
android:textSize="22dp"
/>
</LinearLayout>
</ScrollView>
See the Output screen:
More about ScrollView Click here..
> Scroll View supports only vertical scrolling.
> In ScrollView they cant support Listview placed as child.
See the Example:
<?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="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 1st Text"
android:textSize="12dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 2nd Text"
android:textSize="14dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 3rd Text"
android:textSize="16dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 4th Text"
android:textSize="18dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 5th Text"
android:textSize="20dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 6th Text"
android:textSize="22dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 7th Text"
android:textSize="24dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 8th Text"
android:textSize="26dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 9th Text"
android:textSize="28dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 10th Text"
android:textSize="30dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 11th Text"
android:textSize="32dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 12th Text"
android:textSize="34dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 13th Text"
android:textSize="36dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 14th Text"
android:textSize="38dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 15th Text"
android:textSize="40dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 16th Text"
android:textSize="42dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 17th Text"
android:textSize="44dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 18th Text"
android:textSize="46dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 19th Text"
android:textSize="20dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is 20th Text"
android:textSize="22dp"
/>
</LinearLayout>
</ScrollView>
See the Output screen:
No comments:
Post a Comment