如何设置GridView 的整体宽度自动适应Iiem的个数
1个回答
展开全部
这是我的生成GridView的部分代码:
final GridView gv = new GridView(this);
gv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
gv.setNumColumns(columns);
gv.setGravity(Gravity.CENTER);
gv.setPadding(resource_gridview_padding, resource_gridview_padding, resource_gridview_padding, 0);
gv.setHorizontalSpacing(resource_gridview_HorizontalSpacing);
gv.setVerticalSpacing(resource_gridview_VerticalSpacing);
ResourceGridViewItemAdapter expressionImageAdapter = new ResourceGridViewItemAdapter(this,l);
gv.setAdapter(expressionImageAdapter);
gv.setSelector(R.drawable.selector_resource_item);
gv.setOnItemClickListener(new MyOnItemClickListener(gv));
final GridView gv = new GridView(this);
gv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
gv.setNumColumns(columns);
gv.setGravity(Gravity.CENTER);
gv.setPadding(resource_gridview_padding, resource_gridview_padding, resource_gridview_padding, 0);
gv.setHorizontalSpacing(resource_gridview_HorizontalSpacing);
gv.setVerticalSpacing(resource_gridview_VerticalSpacing);
ResourceGridViewItemAdapter expressionImageAdapter = new ResourceGridViewItemAdapter(this,l);
gv.setAdapter(expressionImageAdapter);
gv.setSelector(R.drawable.selector_resource_item);
gv.setOnItemClickListener(new MyOnItemClickListener(gv));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询