make gridView's cell as square

make grid view as square
需要动态用代码来设置大小,根据设备屏幕大小
int x = AndroidUtil.getScreenSize(context, true);

            int width = (x - 4) / 4;
            view.setLayoutParams(new AbsListView.LayoutParams(width, width));

            ViewGroup.LayoutParams layoutParams = mHolder.imgAvatar.getLayoutParams();
            layoutParams.height = width;
            layoutParams.width = width;
            mHolder.imgAvatar.setLayoutParams(layoutParams);

你可能感兴趣的:(android,GridView)