本文整理了Java中android.widget.GridView.setColumnWidth()
方法的一些代码示例,展示了GridView.setColumnWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.setColumnWidth()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:setColumnWidth
暂无
代码示例来源:origin: TonicArtos/StickyGridHeaders
@Override
public void setColumnWidth(int columnWidth) {
super.setColumnWidth(columnWidth);
mColumnWidth = columnWidth;
}
代码示例来源:origin: UweTrottmann/SeriesGuide
@Override
public void setColumnWidth(int columnWidth) {
super.setColumnWidth(columnWidth);
mColumnWidth = columnWidth;
}
代码示例来源:origin: kymjs/Modularity
@Override
public void setColumnWidth(int columnWidth) {
super.setColumnWidth(columnWidth);
mColumnWidth = columnWidth;
}
代码示例来源:origin: AlexMofer/ProjectX
@Override
public void setColumnWidth(int columnWidth) {
mRequestedColumnWidth = columnWidth;
super.setColumnWidth(columnWidth);
}
代码示例来源:origin: canqihe/TmallSale
@Override
public void setColumnWidth(int columnWidth) {
super.setColumnWidth(columnWidth);
mColumnWidth = columnWidth;
}
代码示例来源:origin: qq8585083/DragIcon
@Override
public void setColumnWidth(int columnWidth) {
mRequestedColumnWidth = columnWidth;
super.setColumnWidth(columnWidth);
}
代码示例来源:origin: stackoverflow.com
float xdpi = this.getResources().getDisplayMetrics().xdpi;
int mKeyHeight = (int) ( xdpi/4 );
GridView gridView = (GridView) findViewById(R.id.gridview);
gridView.setColumnWidth( mKeyHeight );// same Height & Width
代码示例来源:origin: recoilme/freemp
void updateGridView() {
int iDisplayWidth = Math.max(320, getResources().getDisplayMetrics().widthPixels);
int numColumns = iDisplayWidth / 310;
gridView.setColumnWidth((iDisplayWidth / numColumns));
gridView.setNumColumns(numColumns);
gridView.setStretchMode(GridView.NO_STRETCH);
gridView.invalidateViews();
}
代码示例来源:origin: recoilme/freemp
void updateGridView() {
int iDisplayWidth = Math.max(320, getResources().getDisplayMetrics().widthPixels);
int numColumns = iDisplayWidth / 310;
gridView.setColumnWidth((iDisplayWidth / numColumns));
gridView.setNumColumns(numColumns);
gridView.setStretchMode(GridView.NO_STRETCH);
gridView.invalidateViews();
}
代码示例来源:origin: stackoverflow.com
// create a gridview
GridView gridView= new GridView(this);
gridView.setLayoutParams(new GridView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
gridView.setNumColumns(set number of columns here);
gridView.setColumnWidth(GridView.AUTO_FIT);
gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gridView.setAdapter(adapter);
代码示例来源:origin: bilibili/BiliShare
protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) {
GridView grid = new GridView(context);
ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
// no need scroll
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.bili_socialize_shareboard_item, parent, false);
view.setBackgroundDrawable(null);
ImageView image = (ImageView) view.findViewById(R.id.bili_socialize_shareboard_image);
TextView platform = (TextView) view.findViewById(R.id.bili_socialize_shareboard_pltform_name);
ShareTarget target = getItem(position);
image.setImageResource(target.iconId);
platform.setText(target.titleId);
return view;
}
};
grid.setNumColumns(-1);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.bili_socialize_shareboard_size));
grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
grid.setSelector(R.drawable.bili_socialize_selector_item_background);
grid.setAdapter(adapter);
grid.setOnItemClickListener(onItemClickListener);
return grid;
}
代码示例来源:origin: dabutaizha/juzimi
protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) {
GridView grid = new GridView(context);
ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
// no need scroll
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.shareboard_item, parent, false);
view.setBackgroundDrawable(null);
ImageView image = view.findViewById(R.id.shareboard_image);
TextView platform = view.findViewById(R.id.shareboard_pltform);
ShareTarget target = getItem(position);
image.setImageResource(target.iconId);
platform.setText(target.titleId);
return view;
}
};
grid.setNumColumns(3);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.shareboard_size));
grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
grid.setSelector(R.drawable.background_shareboard);
grid.setAdapter(adapter);
grid.setOnItemClickListener(onItemClickListener);
return grid;
}
代码示例来源:origin: stackoverflow.com
GridView grid = new GridView(this);
grid.setId(215236);
grid.setLayoutParams(new GridView.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
grid.setBackgroundColor(Color.WHITE);
grid.setColumnWidth(GridView.AUTO_FIT);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
代码示例来源:origin: stackoverflow.com
GridView grid = new GridView( this );
grid.setColumnWidth( UIScheme.cellSize );
grid.setVerticalSpacing( UIScheme.gap );
grid.setStretchMode( GridView.STRETCH_COLUMN_WIDTH );
grid.setNumColumns( GridView.AUTO_FIT );
代码示例来源:origin: HenriDellal/emerald
grid.setVerticalSpacing((int)(options.getInt(Keys.VERTICAL_SPACING, getResources().getInteger(R.integer.vertical_spacing_default)) * getResources().getDisplayMetrics().density));
if (options.getBoolean(Keys.TILE, true)) {
grid.setColumnWidth((int)(options.getInt(Keys.COLUMN_WIDTH, getResources().getInteger(R.integer.column_width_default)) * getResources().getDisplayMetrics().density));
} else {
grid.setNumColumns(1);
grid.setVerticalSpacing((int)(options.getInt(Keys.VERTICAL_SPACING_LANDSCAPE, getResources().getInteger(R.integer.vertical_spacing_land_default)) * getResources().getDisplayMetrics().density));
if (options.getBoolean(Keys.TILE, true)) {
grid.setColumnWidth((int)(options.getInt(Keys.COLUMN_WIDTH_LANDSCAPE, getResources().getInteger(R.integer.column_width_land_default)) * getResources().getDisplayMetrics().density));
} else {
grid.setNumColumns(2);
grid.setColumnWidth(-1);
代码示例来源:origin: TheMelody/LotteryTrend
/**
* 绑定顶部数据显示:顶部数据只显示在一行;
*/
private void bindHeaderData(){
mHeadData=new ArrayList();
//33个红球+16个蓝球;
for (int i=1;i<=49;i++){
if(i<=33){
//红球区域
mHeadData.add(""+i);
}else{
//蓝球区域
mHeadData.add(""+(i-33));
}
}
DataAdapter adapter= new DataAdapter(R.layout.gridview_item);
adapter.bindData(mHeadData,false);
int deltaDp=getResources().getDimensionPixelSize(R.dimen.item_wh);
//下面的代码是重新定位布局参数;让gridView数据都显示在一行;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(adapter.getCount() * deltaDp,
LinearLayout.LayoutParams.WRAP_CONTENT);
mHeadGridView.setLayoutParams(params);
mHeadGridView.setColumnWidth(deltaDp);//列宽
mHeadGridView.setStretchMode(GridView.NO_STRETCH);//伸展模式
mHeadGridView.setNumColumns(adapter.getCount());//共有多少列
mHeadGridView.setAdapter(adapter);
}
代码示例来源:origin: stackoverflow.com
GridView gridView;
int gridWidth = 1280;
int gridHeight = 500;
int gridItemWidth = 60;
int gridItemHeight = 50;
int gridRows = 3, gridColumns = 4;
int vSpacing = (gridHeight - (gridItemHeight * gridRows))/gridRows;
int hSpacing = (gridWidth - (gridItemWidth * gridColumns))/gridColumns;
gridView.setLayoutParams(new LayoutParams(gridWidth, gridHeight));
gridView.setColumnWidth(gridItemWidth);
gridView.setNumColumns(gridColumns);
gridView.setHorizontalSpacing(hSpacing);
gridView.setVerticalSpacing(vSpacing);
代码示例来源:origin: stackoverflow.com
GridView gv = new GridView(context);
gv.setId(999999);
gv.setLayoutParams(new
GridView.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
gv.setBackgroundColor(Color.GREEN);
gv.setNumColumns(3);
gv.setColumnWidth(GridView.AUTO_FIT);
gv.setVerticalSpacing(5);
gv.setHorizontalSpacing(5);
gv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gv.setGravity(Gravity.CENTER);
代码示例来源:origin: stackoverflow.com
GridView grid = new GridView(this);
grid.setId(ViewIdentification.getId());
grid.setLayoutParams(new GridView.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
grid.setBackgroundColor(Color.WHITE);
grid.setNumColumns(3);
grid.setColumnWidth(GridView.AUTO_FIT);
grid.setVerticalSpacing(5);
grid.setHorizontalSpacing(5);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
代码示例来源:origin: michael-rapp/AndroidBottomSheet
/**
* Shows the grid view, which is used to show the bottom sheet's items.
*/
private void showGridView() {
gridView = contentContainer.findViewById(R.id.bottom_sheet_grid_view);
if (gridView != null) {
contentContainer.setVisibility(View.VISIBLE);
if (getStyle() == Style.GRID) {
int horizontalPadding = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
int paddingBottom = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_padding_bottom);
gridView.setPadding(horizontalPadding, 0, horizontalPadding, paddingBottom);
gridView.setNumColumns(GridView.AUTO_FIT);
gridView.setColumnWidth(getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_size));
} else {
int paddingBottom = getContext().getResources()
.getDimensionPixelSize(R.dimen.bottom_sheet_list_padding_bottom);
gridView.setPadding(0, 0, 0, paddingBottom);
gridView.setNumColumns(getStyle() == Style.LIST_COLUMNS &&
(getDeviceType(getContext()) == DisplayUtil.DeviceType.TABLET ||
getOrientation(getContext()) == DisplayUtil.Orientation.LANDSCAPE) ?
2 : 1);
}
gridView.setOnItemClickListener(createItemClickListener());
gridView.setOnItemLongClickListener(createItemLongClickListener());
gridView.setAdapter(adapter);
}
}
内容来源于网络,如有侵权,请联系作者删除!