I have a GridView and as items for this GridView i use custom layout and an adapter to inflate this custom view at the grid items. but am having a problemwith different screen sizes because the gridview items is not expanding but rather still showing small because the sizes of the custom layout is statically declared. What can i make so that grid view items will take certian % of the screen heigth and width.
Notice:
This Code wont Work
View someView = (View).findViewById(someId):
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
someView .getLayoutParams();
params.height = 130;
someView .setLayoutParams(params);
I Found the solution if anybody is interested.
private int ScreenHeight;
private int ScreenWidth;
DisplayMetrics displaymetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
ScreenHeight = displaymetrics.heightPixels;
ScreenWidth = displaymetrics.widthPixels;
holder.BookItemWraper.setLayoutParams(new android.widget.AbsListView.LayoutParams((int) Math.round(ScreenWidth / 2.1), (int) Math.round(ScreenHeight / 2.5)));