LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT(控件宽),
ViewGroup.LayoutParams.WRAP_CONTENT(控件高),
(float) 1.0(占比));
layoutParams.setMargins(0,dpToPx(20),0,BannerUtils.dp2px(15));
if(position == 0){
holder.linearLayout.setLayoutParams(layoutParams);
}
// px 尺寸转dp
private float dpToPx(float dp){
return TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, dp, view.getResources().getDisplayMetrics());
}