Best code examples for GridView setStretchMode method (android.widget.GridView.setStretchMode)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for GridView setStretchMode method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

GridView setStretchMode examples from Open Source projects
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setStretchMode, setVerticalSpacing
21:	gridView.setHorizontalSpacing(0); 
-
25:	gridView.setColumnWidth(screenWidth / 3 - margin * 2 / 3); 
26:	gridView.setStretchMode(GridView.NO_STRETCH); 
27:	gridView.setHorizontalSpacing(margin / 2); 
28:	gridView.setVerticalSpacing(margin / 2); 
-
30:	gridView.setAdapter(adapter); 
31:	gridView.setRecyclerListener(adapter); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
74:	mGridView = new GridView(mContext); 
75:	mGridView.setNumColumns(4); 
76:	mGridView.setHorizontalSpacing(10); 
77:	mGridView.setVerticalSpacing(10); 
78:	mGridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
79:	mGridView.setGravity(Gravity.CENTER); 
80:	mGridView.setOnItemClickListener(this); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter, setGravity, setNumColumns, setStretchMode, setPadding
157:	gridView = new GridView(mContext); 
-
159:	gridView.setVerticalScrollBarEnabled(false); 
-
161:	gridView.setNumColumns(currentRow.size()); 
162:	gridView.setPadding(1,1,1,1); 
-
164:	gridView.setGravity(Gravity.CENTER); 
165:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
-
173:	gridView.setAdapter(itemAdapter); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setNumColumns, setStretchMode
40:	GridView gridview = new GridView(this); 
41:	gridview.setNumColumns(GridView.AUTO_FIT); 
42:	gridview.setHorizontalSpacing(40); 
43:	gridview.setVerticalSpacing(40); 
44:	gridview.setPadding(20, 20, 20, 0); 
45:	gridview.setFastScrollEnabled(true); 
46:	gridview.setColumnWidth(iconSize); 
47:	gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
-
49:	gridview.setAdapter(new ImageAdapter(this, pkgName)); 
50:	gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
81:	gvTitle = new GridView(activity); 
82:	gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 
-
84:	gvTitle.setNumColumns(4); 
85:	gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
86:	gvTitle.setVerticalSpacing(15); 
87:	gvTitle.setHorizontalSpacing(10); 
88:	gvTitle.setPadding(10, 10, 10, 10); 
89:	gvTitle.setGravity(Gravity.CENTER); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setNumColumns, setStretchMode
22:	GridView gridView = new GridView(context); 
23:	gridView.setNumColumns(4); 
24:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
34:	gridView = new GridView(context); 
35:	gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 
-
37:	gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));// 选中的时候为透明色 
38:	gridView.setNumColumns(bodyAdapter.resID.length); 
39:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
40:	gridView.setVerticalSpacing(0); 
41:	gridView.setHorizontalSpacing(0); 
42:	gridView.setPadding(0, 0, 0, 0); 
43:	gridView.setGravity(Gravity.CENTER); 
44:	gridView.setOnItemClickListener(bodyClick); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setNumColumns, setStretchMode
40:	GridView gridview = new GridView(this); 
41:	gridview.setNumColumns(GridView.AUTO_FIT); 
42:	gridview.setHorizontalSpacing(40); 
43:	gridview.setVerticalSpacing(40); 
44:	gridview.setPadding(20, 20, 20, 0); 
45:	gridview.setFastScrollEnabled(true); 
46:	gridview.setColumnWidth(iconSize); 
47:	gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
-
49:	gridview.setAdapter(new ImageAdapter(this, pkgName)); 
50:	gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setNumColumns, setStretchMode
40:	GridView gridview = new GridView(this); 
41:	gridview.setNumColumns(GridView.AUTO_FIT); 
42:	gridview.setHorizontalSpacing(40); 
43:	gridview.setVerticalSpacing(40); 
44:	gridview.setPadding(20, 20, 20, 0); 
45:	gridview.setFastScrollEnabled(true); 
46:	gridview.setColumnWidth(iconSize); 
47:	gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
-
49:	gridview.setAdapter(new ImageAdapter(this, pkgName)); 
50:	gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setNumColumns, setStretchMode
40:	GridView gridview = new GridView(this); 
41:	gridview.setNumColumns(GridView.AUTO_FIT); 
42:	gridview.setHorizontalSpacing(40); 
43:	gridview.setVerticalSpacing(40); 
44:	gridview.setPadding(20, 20, 20, 0); 
45:	gridview.setFastScrollEnabled(true); 
46:	gridview.setColumnWidth(iconSize); 
47:	gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
-
49:	gridview.setAdapter(new ImageAdapter(this, pkgName)); 
50:	gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
27:	gridView = new GridView(context); 
28:	gridView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 
-
30:	gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));// 选中的时候为透明色 
31:	gridView.setNumColumns(4); 
32:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
33:	gridView.setVerticalSpacing(0); 
34:	gridView.setHorizontalSpacing(0); 
35:	gridView.setPadding(0, 0, 0, 0); 
36:	gridView.setGravity(Gravity.CENTER); 
37:	gridView.setOnItemClickListener(bodyClick); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setAdapter, setGravity, setHorizontalSpacing, setNumColumns, setStretchMode
31:	gvTitle = new GridView(context); 
32:	gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 
-
34:	gvTitle.setNumColumns(titleAdapter.getCount()); 
35:	gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
36:	gvTitle.setVerticalSpacing(1); 
37:	gvTitle.setHorizontalSpacing(1); 
38:	gvTitle.setGravity(Gravity.CENTER); 
39:	gvTitle.setOnItemClickListener(titleClick); 
40:	gvTitle.setAdapter(titleAdapter); 
41:	gvTitle.setSelector(new ColorDrawable(Color.TRANSPARENT));// Ñ¡ÖеÄʱºòΪ͸Ã÷É« 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setColumnWidth, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
124:	GridView lv = new GridView(getActivity()); 
125:	lv.setId(android.R.id.list); 
126:	lv.setDrawSelectorOnTop(false); 
127:	lv.setColumnWidth(convertDpToPixels(60, getActivity())); 
128:	lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
129:	lv.setNumColumns(GridView.AUTO_FIT); 
130:	lv.setHorizontalSpacing(convertDpToPixels(20, getActivity())); 
131:	lv.setVerticalSpacing(convertDpToPixels(20, getActivity())); 
132:	lv.setSmoothScrollbarEnabled(true); 
-
136:	lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setAdapter, setGravity, setHorizontalSpacing, setNumColumns, setStretchMode
30:	title = new GridView(context); 
31:	title.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
32:	title.setNumColumns(titleAdapter.getCount()); 
33:	title.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
34:	title.setVerticalSpacing(1); 
35:	title.setHorizontalSpacing(1); 
36:	title.setGravity(Gravity.CENTER); 
37:	title.setOnItemClickListener(titleClick); 
38:	title.setAdapter(titleAdapter); 
39:	title.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色 
Full Snippet Info
4
CodeRank
Related GridView setStretchMode Questions & Answers:
Other GridView setStretchMode Examples
52:			gridView.setNumColumns(AppConstant.NUM_OF_COLUMNS);
53:			gridView.setColumnWidth(columnWidth);
54:			gridView.setStretchMode(GridView.NO_STRETCH);
55:			gridView.setPadding((int) padding, (int) padding, (int) padding,
56:					(int) padding);

Read More

A view that shows items in two-dimensional scrolling grid. The items in the grid come from the ListAd...
setStretchMode Method Overview
Control how items are stretched to fill their space.
See Also
  • getAdapter
    Returns the adapter currently associated with this widget.
  • setHorizontalSpacing
    Set the amount of horizontal (x) spacing to place between each item in the grid.
  • setVerticalSpacing
    Set the amount of vertical (y) spacing to place between each item in the grid.