Example usage for android.widget GridView requestLayout

List of usage examples for android.widget GridView requestLayout

Introduction

In this page you can find the example usage for android.widget GridView requestLayout.

Prototype

@Override
    public void requestLayout() 

Source Link

Usage

From source file:com.optimusinfo.elasticpath.cortex.common.Utils.java

/**
 * This methods sets the gridview height
 * //w ww  .  ja v a 2  s . c  o  m
 * @param gridView
 */
public static void setSingleCoulmnGridViewHeightBasedOnChildren(GridView gridView) {
    ViewGroup.LayoutParams params = gridView.getLayoutParams();
    int size = gridView.getAdapter().getCount();
    int dynamicHeight = Utils.getTotalHeightofListView(gridView);
    params.height = (dynamicHeight) + (dynamicHeight / size);
    gridView.setLayoutParams(params);
    gridView.requestLayout();
}

From source file:com.optimusinfo.elasticpath.cortex.common.Utils.java

/**
 * This methods sets the gridview height
 * //from w ww .  j av  a2  s . com
 * @param gridView
 */
public static void setGridViewHeightBasedOnChildren(GridView gridView, int columncount) {
    ViewGroup.LayoutParams params = gridView.getLayoutParams();
    int size = gridView.getAdapter().getCount();
    int dynamicHeight = Utils.getTotalHeightofListView(gridView);
    if (size % columncount == 0) {
        params.height = (dynamicHeight / columncount) + 25;
    } else {
        params.height = (dynamicHeight / columncount) + (dynamicHeight / size);
    }
    gridView.setLayoutParams(params);
    gridView.requestLayout();
}

From source file:ua.boberproduction.bbr.BaseActivity.java

private boolean closeNavigationDrawer() {
    if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
        drawerLayout.closeDrawer(GravityCompat.START);
        Fragment fragment = getFragmentManager().findFragmentById(R.id.main_frame);
        if (fragment instanceof MainMenuFragment) {
            GridView gridLayout = (GridView) findViewById(R.id.grid_menu);
            if (null != gridLayout) {
                gridLayout.invalidate();
                gridLayout.requestLayout();
            }//  w w w.  j a  va  2s  .  co  m
        }
        return true;
    }
    return false;
}