本文整理了Java中android.widget.GridView.setGravity()
方法的一些代码示例,展示了GridView.setGravity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.setGravity()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:setGravity
暂无
代码示例来源:origin: jelic98/dynamico
gridView.setGravity(Gravity.START);
}else if(gravity.equalsIgnoreCase("top")) {
gridView.setGravity(Gravity.TOP);
}else if(gravity.equalsIgnoreCase("end")) {
gridView.setGravity(Gravity.END);
}else if(gravity.equalsIgnoreCase("bottom")) {
gridView.setGravity(Gravity.BOTTOM);
}else if(gravity.equalsIgnoreCase("center")) {
gridView.setGravity(Gravity.CENTER);
}else if(gravity.equalsIgnoreCase("center_horizontal")) {
gridView.setGravity(Gravity.CENTER_HORIZONTAL);
}else if(gravity.equalsIgnoreCase("center_vertical")) {
gridView.setGravity(Gravity.CENTER_VERTICAL);
代码示例来源:origin: stackoverflow.com
appSectionGridView.setHorizontalSpacing(10);
appSectionGridView.setNumColumns(3);
appSectionGridView.setGravity(Gravity.CENTER);
appSectionGridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
appSectionGridView.setOnItemClickListener(new OnItemClickListener() {
代码示例来源: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: freedom10086/Ruisi
private void init() {
String[] colors = mContext.getResources().getStringArray(R.array.color_list);
for (int i = 0; i < colors.length; i++) {
if (colorDatas == null) {
colorDatas = new String[colors.length][2];
}
colorDatas[i][0] = colors[i].split(",")[0];
colorDatas[i][1] = colors[i].split(",")[1];
}
gridView = new GridView(mContext);
gridView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
gridView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.white));
gridView.setNumColumns(8);
gridView.setPadding(DimenUtils.dip2px(mContext, 8), DimenUtils.dip2px(mContext, 12), DimenUtils.dip2px(mContext, 8), DimenUtils.dip2px(mContext, 12));
gridView.setGravity(Gravity.CENTER);
gridView.setHorizontalSpacing(DimenUtils.dip2px(mContext, 4));
gridView.setVerticalSpacing(DimenUtils.dip2px(mContext, 12));
gridView.setOnItemClickListener(this);
setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.rec_solid_primary_bg));
setFocusable(true);
setContentView(gridView);
adapter = new MyAdapter();
gridView.setAdapter(adapter);
}
代码示例来源:origin: stackoverflow.com
gv.setHorizontalSpacing(10);
gv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gv.setGravity(Gravity.CENTER);
代码示例来源:origin: stackoverflow.com
gv.setHorizontalSpacing(10);
gv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gv.setGravity(Gravity.CENTER);
代码示例来源:origin: MinTate/Mleaf
category.setColumnWidth(300);//每个单元格宽度
category.setGravity(Gravity.CENTER);//设置对其方式
内容来源于网络,如有侵权,请联系作者删除!