HorizontalScrollView ScrollView horizontal vertical Android xml example

HorizontalScrollView ScrollView LinearLayout horizontal vertical Android xml basic example and image.

horizontalscrollview-android

horizontal scrollview horizontalscrollview android

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
	android:layout_width="fill_parent" android:layout_height="fill_parent"
	xmlns:android="http://schemas.android.com/apk/res/android">
 
	// horizontal and vertical Scrollview
	<ScrollView android:id="@+id/ScrollView01"
		android:layout_height="135px" android:layout_width="wrap_content"
		android:scrollbars="horizontal|vertical">
 
		// HorizontalScrollview
		<HorizontalScrollView android:id="@+id/HorizontalScrollView01"
			android:layout_height="fill_parent" android:layout_width="wrap_content">
 
			<LinearLayout android:id="@+id/LinearLayout02"
				android:layout_width="wrap_content" android:orientation="vertical"
				android:layout_height="fill_parent">
				<LinearLayout android:orientation="horizontal"
					android:layout_width="fill_parent" android:layout_height="fill_parent"
					android:layout_weight="1">
					<TextView android:text="red" android:gravity="center_horizontal"
						android:background="#aa0000" android:layout_width="200px"
						android:layout_height="fill_parent" android:layout_weight="1" />
					<TextView android:text="green" android:gravity="center_horizontal"
						android:background="#00aa00" android:layout_width="200px"
						android:layout_height="fill_parent" android:layout_weight="1" />
					<TextView android:text="blue" android:gravity="center_horizontal"
						android:background="#0000aa" android:layout_width="200px"
						android:layout_height="fill_parent" android:layout_weight="1" />
					<TextView android:text="yellow" android:gravity="center_horizontal"
						android:background="#aaaa00" android:layout_width="200px"
						android:layout_height="fill_parent" android:layout_weight="1" />
				</LinearLayout>
 
				<LinearLayout android:orientation="vertical"
					android:layout_width="fill_parent" android:layout_height="fill_parent"
					android:layout_weight="1">
					<TextView android:text="row one" android:textSize="15pt"
						android:layout_width="fill_parent" android:layout_height="wrap_content"
						android:layout_weight="1" />
					<TextView android:text="row two" android:textSize="15pt"
						android:layout_width="fill_parent" android:layout_height="wrap_content"
						android:layout_weight="1" />
					<TextView android:text="row three" android:textSize="15pt"
						android:layout_width="fill_parent" android:layout_height="wrap_content"
						android:layout_weight="1" />
					<TextView android:text="row four" android:textSize="15pt"
						android:layout_width="fill_parent" android:layout_height="wrap_content"
						android:layout_weight="1" />
				</LinearLayout>
 
 
			</LinearLayout>
		</HorizontalScrollView>
	</ScrollView>
</LinearLayout>

Other sample

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/layout"
    android:orientation="vertical" >
 
    <HorizontalScrollView
        android:id="@+id/horizontalScrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
 
        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal" >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Hello world! First TextView" />
 
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
 
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />
 
        </LinearLayout>
 
 
 
    </HorizontalScrollView>
 
</LinearLayout>
This entry was posted in Android Examples Code and tagged , , , , . Bookmark the permalink.


Comments are closed.

7,786 views