1
我想通过使用GridView实现以下图像设计,我尝试过使用这些代码行,但未能获得5到6,15和16之间的空白空间,因为它在设计中显示。Android GridView绘图布局
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final ViewHolder holder;
View view = convertView;
if (view == null) {
view = mInflater.inflate(R.layout.table_selection_main_item_list,
parent, false);
holder = new ViewHolder();
assert view != null;
holder.tableSelectionBtn = (TextView) view
.findViewById(R.id.item_table_selection_btn);
holder.viewSideSpace = (View) view.findViewById(R.id.view_right_side);
Log.e("","Table Status ID:::"+tableSelectionList.get(position)
.getTable_selection_table_status_id()+"Count :: "+getCount());
if(((position+1)%5==0)&&((position+1)%10==5)){
gridView.setX(30);
gridView.setHorizontalSpacing(30);
holder.viewSideSpace.setVisibility(View.VISIBLE);
holder.tableSelectionBtn.
gridView.setColumnWidth(180);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout
.LayoutParams.WRAP_CONTENT);
layoutParams.leftMargin = 45;
layoutParams.rightMargin = 45;
layoutParams.topMargin = 45;
layoutParams.bottomMargin = 45;
int size = 150;
GridLayout.LayoutParams layoutParams=new GridLayout.LayoutParams();
layoutParams.setMargins(70,70,70,70);
layoutParams.width=size;
layoutParams.height=size;
holder.tableSelectionBtn.sethor//set(0,0,60,0);
holder.tableSelectionBtn.setLayoutParams(layoutParams);
int pxWidth = (int) (100* Resources.getSystem().getDisplayMetrics().density);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(pxWidth,pxWidth);
llp.setMargins(0, 0, 40, 0); // llp.setMargins(left, top, right, bottom);
holder.tableSelectionBtn.setLayoutParams(llp);
}else{
//holder.viewSideSpace.setVisibility(View.GONE);
int pxWidth = (int) (30* Resources.getSystem().getDisplayMetrics().density);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(pxWidth,pxWidth);
llp.setMargins(0, 0, 0, 0); llp.setMargins(left, top, right, bottom);
holder.tableSelectionBtn.setLayoutParams(llp);
}
} else {
holder = (ViewHolder) view.getTag();
}
,什么是完全失败? –
无法获得5到6,15和16,25和26之间的空格... – Faakhir