LinearLayout layout = new LinearLayout(DeliveryCheckActivity.this);
LinearLayout.LayoutParams lLayoutlayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lLayoutlayoutParams.setMargins(10, 10, 10, 10);
layout.setLayoutParams(lLayoutlayoutParams);
//设置内边距
layout.setPadding(5, 5, 5, 5);
//设置配列方式 水平/垂直
layout.setOrientation(LinearLayout.VERTICAL);
layout.setBackgroundColor(Color.parseColor("#ffffffff"));
//设置LinearLayout
LinearLayout layout1 = new LinearLayout(DeliveryCheckActivity.this);
//设置宽度高度
LinearLayout.LayoutParams lLayoutlayoutParams1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layout1.setLayoutParams(lLayoutlayoutParams1);
//设置内边距
layout1.setPadding(5, 5, 5, 5);
//设置配列方式 水平/垂直
layout1.setOrientation(LinearLayout.HORIZONTAL);
TextView tvMaterialName = new TextView(DeliveryCheckActivity.this);
LinearLayout.LayoutParams etParam1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
tvMaterialName.setLayoutParams(etParam1);
// 设置属性
tvMaterialName.setTextColor(Color.parseColor("#000000"));
String materialInfo = !TextUtils.isEmpty(p.getMaterialName()) ? "物料名称:" + p.getMaterialName() : "物料名称:--";
SpannableString span = SetFontColor(materialInfo, 4, materialInfo.length());
tvMaterialName.setText(span);
//将TextView添加到LinearLayout中
layout1.addView(tvMaterialName);
//layout1.addView(tvSpec);
//将LinearLayout添加到最外层的LinearLayout中
layout.addView(layout1);
//最外层控件
layContent.addView(layout);