Search code examples
androidandroid-layouthorizontalscrollview

Android add views, one next to other horizontally


I have a question that for some with experience may sound stupid, but I can't solve the problem.

I want to add views, one next to other, horizontally, in a scroll view. Can anyone recommend me how to make views to arrange horizontally?

Thanks in advance!


Solution

  • Something like this? These TextViews will scroll horizontally:

    <?xml version="1.0" encoding="utf-8"?>
    <HorizontalScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" android:layout_height="match_parent">
        <LinearLayout android:layout_width="match_parent"
            android:id="@+id/linearLayout1" android:layout_height="match_parent">
            <TextView android:text="TextView" android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView android:text="TextView" android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView android:text="TextView" android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </HorizontalScrollView>