Thursday, January 12, 2012

how to Align first item in Gallery to the left android

This method is used to align item from left side in gallery.

WindowManager wm=(WindowManager) mcontext.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(metrics);

MarginLayoutParams mlp = (MarginLayoutParams) Gallery.getLayoutParams();
mlp.setMargins(-((metrics.widthPixels/2)+100), 
              mlp.topMargin, 
              mlp.rightMargin, 
              mlp.bottomMargin
);

1 comment: