Possible Duplicate:
android gallery image position problem
I'm using Gallery view within my app. Now when I run the code. Gallery has default selected item is no 1 which is in center and left side is blank. Instead I want no 1 item should be at left and selected. Also clicking on the any gallery item should not bring that item in the center.
I tired hunting it lot on the groups but not found any solution. Is this possible or not ? If yes then how come?
hey, I kinda got around the very same issue with adjusting the left margin like so:
DisplayMetrics metrics = new DisplayMetrics();
ctx.getWindowManager().getDefaultDisplay().getMetrics(metrics);
Gallery gallery = (Gallery) ctx.findViewById(R.id.gallery);
MarginLayoutParams mlp = (MarginLayoutParams) gallery.getLayoutParams();
mlp.setMargins(-(metrics.widthPixels/2),
mlp.topMargin,
mlp.rightMargin,
mlp.bottomMargin
);
which goes almost to the left edge, but there is a bit of slack (half image width?), which I actually liked;
if you replace
-(metrics.widthPixels/2)
with
-(metrics.widthPixels/2 + YOUR_IMAGE_WIDTH)
it goes all the way to left edge of the screen (provided this gallery is displaying images of same size, which was my case)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With