动态设置视图大小

private void setLinearLayoutParams(View imageView) {
if (mScreenSize == 0 )
mScreenSize = getScreenSize();

int width = ViewGroup.LayoutParams.MATCH_PARENT;

int height = 0;
if (mScreenSize <= 7)
height = LayoutConstants.sVerVideoImgHeight + 165;
else
height = LayoutConstants.sVerVideoImgHeight + 115;

ViewGroup.LayoutParams params = imageView.getLayoutParams();
if (params == null) {
params = new ViewGroup.LayoutParams(width, height);
imageView.setLayoutParams(params);
} else {
params.width = width;
params.height = height;
}
}



动态根据weight添加
LinearLayout.LayoutParams paramsItemView = new LinearLayout.LayoutParams(
0,
ViewGroup.LayoutParams.WRAP_CONTENT, 1);
LinearLayout.addView(convertView,paramsItemView);



posted @ 2017-05-25 16:17  吴添龙  阅读(194)  评论(0编辑  收藏  举报