0

I am having n number of images to be shown in a gridview. Prsently, I'm populating a gridview in an activity with three columns and one row. I provide a separate link to another activity, which populates another Gridview with these n images.

What I intend to do is to put all n images in a single gridview and apply horizontal scroll to it. This should give an impression of scrolling through images in a single row, where n number of columns is variable (Can i set the number of columns programatically?). I need to display three images at a time. The scroll should show next three, and so on till n.

My present Gridview is present in a RelativeLayout as ---

<GridView
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:background="#ffffff"
         android:columnWidth="0dp"
         android:gravity="center"
         android:horizontalSpacing="0dp"
         android:numColumns="3"
         android:stretchMode="columnWidth"
         android:verticalSpacing="0dp" />
Kunal S. Kushwah
  • 883
  • 1
  • 8
  • 19
  • *"I need to display three images at a time. The scroll should show next three, and so on till n."* - So basically the `GridView` would become 'paginated' into chunks of 3 items for every page? Sounds like a [`ViewPager`](http://developer.android.com/reference/android/support/v4/view/ViewPager.html) is what you're after – MH. May 15 '13 at 09:20
  • There is a RelativeLayout inside a LinearLayout where I'm implementing this. A ViewPager will disrupt that. I need to switch the images only, not the whole page. – Kunal S. Kushwah May 15 '13 at 09:33
  • *"A ViewPager will disrupt that. I need to switch the images only, not the whole page."* - That assumption is not correct. A `ViewPager` can be used for any `View` or set of views (`ViewGroup`)'. Quite commonly such a 'page' is a large part of what's on the screen, yes, but it's certainly not a requirement. If you were to make the pages consist of just a `GridView` (that doesn't take up all the screen estate), then that's absolutely possible. – MH. May 15 '13 at 10:42

0 Answers0