Android RelativeLayout 代码位置布局

                       convertView = (RelativeLayout) View.inflate(mContext, R.layout.item_poster_gallery, null);

holder.imageMoviePoster = (ImageView) convertView.findViewById(R.id.imageMoviePoster);
holder.textMovieName = (TextView) convertView.findViewById(R.id.textName);
holder.textMovieAbstruct = (TextView) convertView.findViewById(R.id.textMovieAbstruct);


//ConstMethod.posterHeight ConstMethod.posterWidth
//海报 440x660  边16 阴影120
// 设置海报宽高  
int left=16*ConstMethod.posterWidth/440;// ConstMethod.dip2px(mContext, 7);
int height=16*ConstMethod.posterHeight/660;//ConstMethod.dip2px(mContext, 10);
holder.imageMoviePoster.setPadding(left-1, height-1, left-1, height-1);

//介绍文字
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,

RelativeLayout.LayoutParams.WRAP_CONTENT);

lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lp2.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE);
int bottom2 = 22*ConstMethod.posterHeight/660;
lp2.setMargins(left, 0, left, bottom2);
holder.textMovieAbstruct.setLayoutParams(lp2);

//影片名称
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lp1.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE);
int bottom = 66*ConstMethod.posterHeight/660;
lp1.setMargins(left, 0, left, bottom);
holder.textMovieName.setLayoutParams(lp1);

//海报整体大小
Gallery.LayoutParams rlayoutParams = new Gallery.LayoutParams(
ConstMethod.posterWidth, ConstMethod.posterHeight);
convertView.setLayoutParams(rlayoutParams);

你可能感兴趣的:(Android)