List of usage examples for android.widget GridView NO_STRETCH
int NO_STRETCH
To view the source code for android.widget GridView NO_STRETCH.
Click Source Link
From source file:y2w.ui.activity.MainActivity.java
private void setMenuHorizontal() { adapter = new MainMenuAdapter(); gv_menu.setAdapter(adapter);/*w w w. ja v a 2 s. c o m*/ int size = menus.size(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int height = dm.widthPixels; int itemWidth = height / size; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); gv_menu.setLayoutParams(params); // GirdView?,? gv_menu.setColumnWidth(itemWidth); // gv_menu.setStretchMode(GridView.NO_STRETCH); gv_menu.setNumColumns(size); // ?=? }
From source file:com.narkii.security.info.LicenseInfoFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // TODO Auto-generated method stub if (loader.getId() == Constants.PERMISSION_IMAGE_ID) { int counts = data.getCount(); DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); float density = dm.density; int allWidth = (int) (210 * counts * density); int itemWidth = (int) (200 * density); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(allWidth, LinearLayout.LayoutParams.WRAP_CONTENT); gridView.setLayoutParams(params); gridView.setColumnWidth(itemWidth); gridView.setHorizontalSpacing(10); gridView.setStretchMode(GridView.NO_STRETCH); gridView.setNumColumns(counts);//www . j a va 2 s . c om gridViewAdapter.swapCursor(data); } else if (loader.getId() == Constants.PERMISSION_FILE_ID) { } }