Example usage for android.widget GridView STRETCH_SPACING

List of usage examples for android.widget GridView STRETCH_SPACING

Introduction

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

Prototype

int STRETCH_SPACING

To view the source code for android.widget GridView STRETCH_SPACING.

Click Source Link

Document

Stretches the spacing between columns.

Usage

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SpeakersGridFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final GridView gridView = getGridView();
    float sf = getResources().getDisplayMetrics().density;
    final int padding = (int) (5.0 * sf);
    final int spacing = (int) (20.0 * sf);

    gridView.setNumColumns(GridView.AUTO_FIT);
    gridView.setColumnWidth((int) (120 * sf));
    gridView.setStretchMode(GridView.STRETCH_SPACING);
    gridView.setVerticalFadingEdgeEnabled(true);
    gridView.setPadding(padding, padding, padding, padding);
    gridView.setHorizontalSpacing(spacing);
    gridView.setVerticalSpacing(spacing);
}