Android horizontalscrollview example

Source: Internet
Author: User

In Android, We can scroll the elements in both horizontal and vertical format. To scroll in vertical we can use scrollview, to scroll in horizontal format we need to use horizontalscrollview.
Example for horizontalscrollview :-

01 <?xml version="1.0" encoding="utf-8"?>
02 <LinearLayout android:id="@+id/LinearLayout01"
03 android:layout_width="fill_parent"
04 android:layout_height="fill_parent"
05 xmlns:android="http://schemas.android.com/apk/res/android">
06 // Adding Scrollview
07 <ScrollView android:id="@+id/ScrollView01"
08 android:layout_height="110px"
09 android:layout_width="wrap_content"
10 android:scrollbars="horizontal|vertical">
11 // Adding HorizontalScrollview
12 <HorizontalScrollView android:id="@+id/HorizontalScrollView01"
13 android:layout_height="fill_parent"
14 android:layout_width="wrap_content">
15 <LinearLayout android:id="@+id/LinearLayout02"
16 android:layout_width="wrap_content"
17 android:orientation="vertical"
18 android:layout_height="fill_parent">
19 <Button android:text="1"
20 android:id="@+id/Button01"
21 android:layout_width="wrap_content"
22 android:layout_height="wrap_content" />
23 <Button android:text="2"
24 android:id="@+id/Button02"
25 android:layout_height="wrap_content"
26 android:layout_width="400px" />
27 <Button android:text="3"
28 android:id="@+id/Button03"
29 android:layout_width="wrap_content"
30 android:layout_height="wrap_content" />
31 </LinearLayout>
32 </HorizontalScrollView>
33 </ScrollView>
34 </LinearLayout>

The output will looks like

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.