0

The ScrollView in the layout has three Imageviews which has drawable images set as its background.The dimensions of ImageViews are 150dp. I have set the height of the ScrollView to wrap_content and scrollbars attribute to horizontal.But it does not scroll.Please help me with the problem.

Code:

<ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/offerscroll"
            android:scrollbars="horizontal"
            android:layout_below="@+id/offr_prsnl_chs_pht"
            >
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <ImageView
                    android:layout_width="@dimen/prsnl_img_dimen"
                    android:layout_height="@dimen/prsnl_img_dimen"
                    android:id="@+id/offr_img1"
                    android:background="@drawable/ambulance"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="15dp"/>
                <ImageView
                    android:layout_width="@dimen/prsnl_img_dimen"
                    android:layout_height="@dimen/prsnl_img_dimen"
                    android:id="@+id/offr_img2"
                    android:background="@drawable/ambulance"
                    android:layout_marginLeft="5dp"
                    android:layout_marginTop="15dp"/>
                <ImageView
                    android:layout_width="@dimen/prsnl_img_dimen"
                    android:layout_height="@dimen/prsnl_img_dimen"
                    android:id="@+id/offr_img3"
                    android:background="@drawable/ambulance"
                    android:layout_marginLeft="5dp"
                    android:layout_marginTop="15dp"/>

            </LinearLayout>
        </ScrollView>
jobin
  • 1,489
  • 5
  • 27
  • 52
  • Maybe u'r finding this : [http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizontal-in-android](http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizontal-in-android) – Tuhin Subhra Mar 05 '17 at 06:40

3 Answers3

2

why not using a HorizontalScrollView instead

 <HorizontalScrollView
    android:id="@+id/offerscroll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:measureAllChildren="false"
    android:layout_below="@+id/offr_prsnl_chs_pht"
    android:scrollbars="horizontal" >


    </HorizontalScrollView>
rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
0

Use HorizontalScrollView . It should solve your problem

Angelo Parente
  • 796
  • 2
  • 6
  • 15
0

As far as your code goes there is no problem so there can be a possibility:

Size of images(dimen values) satisfy the layout size i.e. no scrolling might be needed.

See if changing that works for you.