动态设置RecyclerView的高度


View view = LayoutInflater.from(mContext).inflate(R.layout.help_recycler, parent, false); //动态设置View高度,解决‘查看更多’上下偏移问题 final float scale = mContext.getResources().getDisplayMetrics().density; int imageHeiht = (int) (102 * scale + 0.5f);//dp转px if(viewType== HelpTipsUtil.TYPE_IMAGE){   view.getLayoutParams().height = imageHeiht;//动态设置View高度 } MyViewHolder holder = new MyViewHolder(view); view.setOnClickListener(new View.OnClickListener() {   @Override   public void onClick(View v) {     if (mOnHelpItemClickListener != null) {       mOnHelpItemClickListener.onItemClick(v, (String) v.getTag(), mHelpTipsEntry);     }   } }); return holder;

 @override

 onCreateViewHolder(){}

posted @ 2017-09-25 09:06  代码の足迹  阅读(16039)  评论(0编辑  收藏  举报