Tuesday, March 13, 2012

How to set gallery starts from left corner?


/*
             * A structure describing general information about a display, such as
             * its size, density, and font scaling.To access the DisplayMetrics
             * members, initialize an object like this:
             */

            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);

            Gallery g = (Gallery) findViewById(R.id.gallery);

            // set gallery to left side
            MarginLayoutParams mlp = (MarginLayoutParams) g.getLayoutParams();
            mlp.setMargins(-(metrics.widthPixels / 2 + (imageWidth/2)), mlp.topMargin,
                        mlp.rightMargin, mlp.bottomMargin);
            




1 comment:

Anonymous said...

hey that code not working properly.try to corrupt mistakes