Height of screen without status bar, actionBar and tabs
You can use this code:
public int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}
as described here: https://stackoverflow.com/a/3410200/1763138
Please try using this solution and tell us if it worked. ;)
Based on @rasmeta 's answer I made this code and it does the trick. My rows are now exactly a third of the available screen. Here is how to get the height of the status bar:
int resource = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resource > 0) {
statusBarHeight = context.getResources().getDimensionPixelSize(resource);
}
And the calculation of the height of each row goes like this:
holder.imageView.getLayoutParams().height = (screenHeight - statusBarHeight - actionBarHeight*2) / 3;
// actionBarHeight * 2 because the tabs have the same height as the actionBar.