Horizontal ScrollView

by / Monday, 05 August 2013 / Published in Android

HorizontalScrollView is a Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A HorizontalScrollView is a FrameLayout, meaning you should place one child 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 LinearLayout in a horizontal orientation, presenting a horizontal array of top-level items that the user can scroll through.Horizontal ScrollView is used to scroll all contents of a screen horizontally.

code :

code for layout:

<HorizontalScrollView
android:id="@+id/horizontalscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30pt"
android:text="@string/hello_world" />
</HorizontalScrollView>

code for activity :

HorizontalScrollView hscroll=new HorizontalScrollView(this); //create a horizontal scrollview and add a child view (textview) in it
TextView txt=new TextView(this);
hscroll.addView(txt);

 

 

TOP