How to center a gallery

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to center a gallery

Postby timweicker » Mon Jul 13, 2009 6:40 pm

Hey there!

I've got a simple question: Is there any way to center the "standard-gallery" given in the "Hello, Views"-tutorial? Because it always starts with the first element in the ImageAdapter-String-array, and so it always starts on the left - Is there any method to say "focus and center the gallery on the x-th element of the gallery"?

Thanks for your help!

Junior Developer
Junior Developer
Posts: 20
Joined: Wed Jun 10, 2009 7:55 pm


Postby phannguyen » Thu Jul 16, 2009 4:09 am

you find the mid-index of ImageAdapter-String-array and then can use
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. mGallery.setSelection(mid-index);
Parsed in 0.013 seconds, using GeSHi

Experienced Developer
Experienced Developer
Posts: 56
Joined: Thu Jul 17, 2008 7:37 am


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests